Please tell me how to determine the value of a function handle in a quick way.
hf12 = @(age) exp(-0.0625.*age-0.0134) % exp(age effect+time effect)
hf13 = 0hf14 = 0hf15 = @(age) exp(-9.65573+0.01844+0.08218*age+0.02246) % exp(intercept+ age effect+time effect)
hf11 = 0hf21 = 0hf23 = @(age) exp(-1.6660-0.1116.*age-0.0025) % exp(intercept+ age effect+time effect) hf24 = @(age)exp(-8.96236+0.07691.*age + 0.00978) % assuming the death rate of male of same age(Hubener et al.)
hf25 = @(age)exp(-9.65573+0.08218.*age+0.02246) % self-mortality
hf22 = 0hf31 = 0hf32 = @(age) exp(-0.0625.*age-0.0134+0.0676) %exp(intercept+ age effect+time effect+marriage once before)
hf34 = 0hf35 = @(age) exp(-9.65573+0.08218.*age+0.02246-0.11853)hf33 = 0hf41 = 0hf42 = @(age) exp(-0.4176-0.0625-0.0134.*age)hf43 = 0hf45 = @(age) exp(-9.65573+0.08218.*age+0.02246-0.00415) %exp(intercept+ age effect+time effect+widowhood effect)
hf44 = 0hf51 = 0hf52 = 0hf53 = 0hf55 = 0hf54 = 0age =30% Evaluate matrix Q at age=30
Q30 = [-(hf15(30)+hf12(30)), hf12(30), hf13, hf14, hf15(30); ... hf21, -(hf23(30)+hf25(30)), hf23(30), hf24(30), hf25(30); ... hf31, hf32(30), -(hf32(30)+hf35(30)), hf34, hf35(30); ... hf41, hf42(30), hf43, -(hf42(30)+hf45(30)), hf45(30); ... hf51, hf52, hf53, hf54, hf55]
It takes so long if I have to determine Q matrix for each age from 20 to 100 years. I want to figure out, how can I do this in some loop or some other way like:
% put all function handles in a matrix like
Q = [h11, hf12, hf13, hf14, hf15; ... hf21, h22, hf23, hf24, hf25; ... hf31, hf32, h33, hf34, hf35; ... hf41, hf42, hf43, h44, hf45; ... hf51, hf52, hf53, hf54, hf55]% and then determine Q for each age
% Determine the value of "Q" for ages 20 to 100.
Best Answer