<http://spssx-discussion.1045642.n5.nabble.com/file/t341148/Mig_model.jpg>
<http://spssx-discussion.1045642.n5.nabble.com/file/t341148/mig_model2.jpg> <http://spssx-discussion.1045642.n5.nabble.com/file/t341148/mig_model3jpg.jpg> <http://spssx-discussion.1045642.n5.nabble.com/file/t341148/Mig_model4.jpg> I really need a help... I am trying to learn how to use properly non-linear regression. I got some data (I pasted some below) and theory about modelling this type of data. I attached few scans. My DATA is vary similar to what others researchers used on theirs examples. I want to reproduce step by step all process. The equation for modelling this type of data is known, I need to find parameters, I tried to do this with NLR, but I failed...;( DATASET CLOSE all. new file. data list list /age(f8.0) age_s(a3) var(f8.5). begin data. 0 0 ,01491 1 1 ,03406 2 2 ,03537 3 3 ,04037 4 4 ,03079 5 5 ,02825 6 6 ,03621 7 7 ,02539 8 8 ,01810 9 9 ,01694 10 10 ,01718 11 11 ,01457 12 12 ,01602 13 13 ,01887 14 14 ,01079 15 15 ,01001 16 16 ,01013 17 17 ,00805 18 18 ,01308 19 19 ,00751 20 20 ,00653 21 21 ,00691 22 22 ,00930 23 23 ,01236 24 24 ,01734 25 25 ,02035 26 26 ,02734 27 27 ,03293 28 28 ,03696 29 29 ,03391 30 30 ,03638 31 31 ,03580 32 32 ,03183 33 33 ,03198 34 34 ,03009 35 35 ,02749 36 36 ,02683 37 37 ,02367 38 38 ,02265 39 39 ,02017 40 40 ,01838 41 41 ,01531 42 42 ,01493 43 43 ,01367 44 44 ,01318 45 45 ,01108 46 46 ,01015 47 47 ,00850 48 48 ,01000 49 49 ,00708 50 50 ,00901 51 51 ,00791 52 52 ,00680 53 53 ,00732 54 54 ,00706 55 55 ,00711 56 56 ,00702 57 57 ,00823 58 58 ,00689 59 59 ,00718 60 60 ,00737 61 61 ,00806 62 62 ,00667 63 63 ,00763 64 64 ,00811 65 65 ,00661 66 66 ,00654 67 67 ,00708 68 68 ,00602 69 69 ,00607 70 70+ ,00529 end data. execute. dataset name b1. DATASET ACTIVATE b1. *to make interval variable for aggregation recode age (lo thru 5=5) (lo thru 10=10) (lo thru 15=15) (lo thru 20=20) (lo thru 25=25) (lo thru 30=30) (lo thru 35=35) (lo thru 40=40) (lo thru 45=45) (lo thru 50=50) (lo thru 55=55) (lo thru 60=60) (lo thru 65=65) (lo thru 70=70) into age_c. EXECUTE. *Aggregation with mean AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=age_c /var5years=mean(var). *Interpolation - cubic splines with knots do repeat a = 1 to 14/ b=knot1 to knot14. compute b=a*5. end repeat. execute. do repeat a=knot1 to knot14 / b=k1 to k14. do if a le age. compute b=1. else. compute b=0. end if. end repeat. execute. DATASET ACTIVATE b1. DATASET DECLARE res_int. MODEL PROGRAM c0=0 c1=0 c2=0 c3=0 b3=0 b4=0 b5=0 b6=0 b7=0 b9=0 b10=0 b12=0 b13=0 b14=0 . COMPUTE pred_int = c0 + c1*age + c2*(age**2) + c3*(age**3) + b3*((age-knot3)**3)*k3 + b4*((age-knot4)**3)*k4 + b5*((age-knot5)**3)*k5 + b6*((age-knot6)**3)*k6 + b7*((age-knot7)**3)*k7 + b9*((age-knot9)**3)*k9 + b10*((age-knot10)**3)*k10 + b12*((age-knot12)**3)*k12 + b13*((age-knot13)**3)*k13 + b14*((age-knot14)**3)*k14 . NLR var5years /OUTFILE='res_int' /PRED pred_int /SAVE PRED /CRITERIA SSCONVERGENCE 1E-8 PCON 1E-8. *to see fitted values DATASET ACTIVATE b1. GRAPH /line(MULTIPLE)=value(var var5years pred_int). *I read that sum of all observation need to equal 1. FREQUENCIES VARIABLES pred_int /STATISTICS=sum /FORMAT=NOTABLE. compute pred_int = pred_int/1.17. execute. FREQUENCIES VARIABLES pred_int /STATISTICS=sum /FORMAT=NOTABLE. *Using NLR to find parameter's value, equations (exponential) are known. *Below equation with 11 parameters dataset declare res. MODEL PROGRAM a1=0 alfa1=0 a2=0 alfa2=0 mi2=0 lambda2=0 a3=0 alfa3=0 mi3=0 lambda3=0 c=0. COMPUTE pred=a1*exp(-alfa1*age) + a2*exp(-alfa2*(age-mi2)-exp(-lambda2*(age-mi2))) + a3*exp(-alfa3*(age-mi3)-exp(-lambda3*(age-mi3))) + c. NLR pred_int /OUTFILE='res' /PRED pred /SAVE PRED RESID /CRITERIA SSCONVERGENCE 1E-8 PCON 1E-8. *to see predicted values GRAPH /LINE(MULTIPLE)=value(pred pred_int var). *it is quite good fit on this graph, but I don't understand two things right now: *1) Why when I use estimated parameters and put them into original equation values *are far away from what was saved in dataset earlier as "pred" with NLR command? *Why predicted values (NLR command) and predicted got after filling original equation with estimated values are not the same?????? *estimates values as variables dataset activate b1. compute a1=8.215. compute alfa1=-0.004. compute a2=-11.932. compute alfa2=-0.014. compute mi2=17.708. compute lambda2=-0.005. compute a3=-0.063. compute alfa3=-0.052. compute mi3=22.799. compute lambda3=-0.192. compute c=-4.408. EXECUTE. *using estimated values in original equation COMPUTE pred4=a1*exp(-alfa1*age) + a2*exp(-alfa2*(age-mi2)-exp(-lambda2*(age-mi2))) + a3*exp(-alfa3*(age-mi3)-exp(-lambda3*(age-mi3))) + c. EXECUTE. * This is not the same....why? GRAPH /line(MULTIPLE)=value(pred pred4). *2) Second problem might (or might not) be consequence of first problem, but i will ask anyway. * Parameters, which I got are far away from typical range, (why I am not surprised;) ) e.g. a2 need to be within 0.5 - 0.10 . When my estimated values are out of range i lose ability to interpret phenomenon what * i try to analyse. *But my first question is fundamental, I don't even know whether I found (or not) right parameters.... -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |