Dear Brian,
The errors in variables analysis does just allow for one level of variation
in the analysis. If you mean the replicates you will have this situation.
However, the replicates do allow you to look at the level of variation
in X and Y to estimate the value of VRATIO. Note that averaging the
observations also reduces the problem with the bias in the
ordinary least squares estimator. Below is some code that simulates
your situation using made up data. Note how the mean OLS slope
is biased downwards, and that this is improved when you mean the
replicates for subjects (OLS_MSlope). The mean slopes of the error in
variables regression is about the same whether meaned or not, so
there is no bias in this, but the standard deviation of the slopes is
slightly less for the meaned case, which is repeatable suggests taking
the means is a good thing.
SCALAR NSim; 1000
VARIATE [NV=NSim] OLS_Slope,EIV_Slope,OLS_MSlope,EIV_MSlope
FOR [NTIMES=NSim;INDEX=i]
FACTOR [LEVELS=10] Subject; !(4(1...10))
CALC X = !(4(1...10))/10
CALC XE = X + GRUNIFORM(40;0;1) "Add random variation"
CALC YE = X + GRUNIFORM(40;0;1) "True slope is 1 and VRATIO is 1"
MODEL YE "Ordinary LS estimate"
FIT [PRINT=*] XE
RKEEP EST=Est
RLFUNC [PRINT=*;METHOD=errorsinvariables;VRATIO=1;PLOT=*] YE; XE;
SLOPE=Slp
CALC (OLS_Slope,EIV_Slope)$[i] = Est$[2],Slp "Save estimates from all
points"
TABULATE [CLASS=Subject] XE,YE; MEANS=TX,TY "Mean by subject"
VTABLE TX,TY; XM,YM "Copy tables into variates"
MODEL YM "Ordinary LS estimate on means"
FIT [PRINT=*] XM
RKEEP EST=Est
RLFUNC [PRINT=*;METHOD=errorsinvariables;VRATIO=1;PLOT=*] YM; XM;
SLOPE=Slp
CALC (OLS_MSlope,EIV_MSlope)$[i] = Est$[2],Slp "Save estimates from
means"
PRINT [IP=*;SQ=Yes] i; DEC=0 "Track simulations"
ENDFOR
PRINT MEAN(OLS_Slope,EIV_Slope,OLS_MSlope,EIV_MSlope)
PRINT SD(OLS_Slope,EIV_Slope,OLS_MSlope,EIV_MSlope)
Which on a run on my PC gives:
MEAN(OLS_Slope) MEAN(EIV_Slope) MEAN(OLS_MSlope)
MEAN(EIV_MSlope)
0.5132 1.038 0.8477
1.034
SD(OLS_Slope) SD(EIV_Slope) SD(OLS_MSlope) SD(EIV_MSlope)
0.1202 0.3083 0.1896
0.2507
NB. A quick way of getting a spreadsheet of means and standard deviations
or variances per subject is to use the Spread | Calculate | Summary Stats
menu and put subjects as groups and chose the statistics for each variable
you want.
Regards, David.
______________________________________________
Dr David Baird Statistical Consultant and GenStat Developer
VSN (NZ) Limited ([log in to unmask])
8 Mariposa Crescent, Aidanfield, Christchurch 8025, New Zealand
Ph +64 3 3350588 Cell +64 21 1160803
> From: GENSTAT-Request [mailto:[log in to unmask]] On Behalf Of Brian
> Glasberg
> Sent: 7 November 2012 2:50 a.m.
> To: [log in to unmask]
> Subject: Regression with errors in both variables
>
> Dear List,
>
> Regression with errors in both variable
> with repeated measures
>
> I have a set of data from 51 subjects each of whom
> were tested in two conditions, Noise and Speech.
> There were four replicates in each condition giving
> 51 by 4 pairs of results
>
> The data look like this:
>
> subject replicate Noise Speech
> 1 1 -7.8 -5.8
> 1 2 -7.2 -8.2
> 1 3 -6.5 -21.7
> 1 4 -13.8 -22.1
> 2 1 -2.5 -9.3
> .......
>
> for all 51 subjects.
>
>
> I would like to carry out a regression with
> errors in both variables. My understanding
> is that this can be done on the mean values of
> each subjects' 4 replicates as long as the
> standard deviations of each mean value is
> taken into account.
> (Numerical Recipes in C 2nd ed).
>
> Using Genstat 15's Linear Functional Relationship menu
> and selecting "Errors in variables" as the model
> I can get an overall fit to the 4 X 51 pairs of data
> where I don't know how to tell Genstat that there
> are four replicates.
> Or can just use the 51 mean values which ignores the
> variability across each of the four repeats.
>
> Hope this makes sense!
> Any advice would be welcome.
>
> Brian Glasberg
> Dept Experimental Psychology, Cambridge University, Downing Street
> Cambridge CB2 3EB, England
> Tel: 01223 333652
|