Good day R-Users, I have a problem accessing some values in the output from the summary of an lme fit. The structure of my data is as shown below (I have attached a copy of the full data). id trials endp Z.sas ST 1 1 -1 -1 42.42884 1 1 1 -1 48.12007 2 1 -1 -1 43.42878 2 1 1 -1 46.82817 3 1 -1 -1 45.56736 . 598 10 -1 1 49.59715 598 10 1 1 55.46324 599 10 -1 1 46.80873 599 10 1 1 53.52223 600 10 -1 1 48.58257 600 10 1 1 56.78674 I used the following code to fit my model of interest: ggg <- lme (ST~ -1 + as.factor(endp):Z.sas + as.factor(endp), data=dat4a, random=~-1 + as.factor(endp) + as.factor(endp):Z.sas|as.factor(trials), correlation = corSymm(form=~1|as.factor(trials)/as.factor(id)), weights=varIdent(form=~1|endp)) hh <- summary(ggg) hh Below is the following part of the output of interest I wish to access: Correlation Structure: General Formula: ~1 | as.factor(trials)/as.factor(id) Parameter estimate(s): Correlation: 1 2 0.785 Variance function: Structure: Different standard deviations per stratum Formula: ~1 | endp Parameter estimates: -1 1 1.0000000 0.9692405 I wish to access the value of the correlation (0.785) and the vector of the variance function estimates (1, 0.969). I know these can be done through the intervals function, but sometimes when the estimated Hessian matrix is not positive definite or something like that (i am not quite sure), the intervals function delivers an error message. Thus, i will like to ask if there is another way to access these values. I tried using the following code: hh$modelStruct$corStruct[1] hh$modelStruct$varStruct[1] Rather the output was: > hh$modelStruct$corStruct[1] [1] -1.308580> hh$modelStruct$varStruct[1][1] -0.03124255 I presume there is a way to calculate the correlation and variance function coefficients using these values. Could you tell me how to access those values (without using the intervals function) or better still how to calculate the values from the last output values. Kind regards Pryseley __________________________________________________ -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: dat4a.txt Url: https://stat.ethz.ch/pipermail/r-help/attachments/20060601/49b07c35/attachment.txt
Pryseley: You asked this question last week and received answers to that question along with other suggestions from Doug Bates and myself. Is there some reason the post by Andrew Robinson is not working? Harold> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Pryseley Assam > Sent: Thursday, June 01, 2006 6:25 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Help: lme > > Good day R-Users, > > I have a problem accessing some values in the output from > the summary of an lme fit. > > > The structure of my data is as shown below (I have attached a > copy of the full data). > > > id trials endp Z.sas ST > 1 1 -1 -1 42.42884 > 1 1 1 -1 48.12007 > 2 1 -1 -1 43.42878 > 2 1 1 -1 46.82817 > 3 1 -1 -1 45.56736 > ........................................... > 598 10 -1 1 49.59715 > 598 10 1 1 55.46324 > 599 10 -1 1 46.80873 > 599 10 1 1 53.52223 > 600 10 -1 1 48.58257 > 600 10 1 1 56.78674 > > I used the following code to fit my model of interest: > > ggg <- lme (ST~ -1 + as.factor(endp):Z.sas + > as.factor(endp), data=dat4a, > random=~-1 + as.factor(endp) + > as.factor(endp):Z.sas|as.factor(trials), > correlation = > corSymm(form=~1|as.factor(trials)/as.factor(id)), > weights=varIdent(form=~1|endp)) > > hh <- summary(ggg) > hh > > Below is the following part of the output of interest I > wish to access: > > Correlation Structure: General > Formula: ~1 | as.factor(trials)/as.factor(id) Parameter estimate(s): > Correlation: > 1 > 2 0.785 > Variance function: > Structure: Different standard deviations per stratum > Formula: ~1 | endp > Parameter estimates: > -1 1 > 1.0000000 0.9692405 > > I wish to access the value of the correlation (0.785) and > the vector of the variance function estimates (1, 0.969). I > know these can be done through the intervals function, but > sometimes when the estimated Hessian matrix is not positive > definite or something like that (i am not quite sure), the > intervals function delivers an error message. > > Thus, i will like to ask if there is another way to access > these values. I tried using the following code: > > hh$modelStruct$corStruct[1] > hh$modelStruct$varStruct[1] > > Rather the output was: > > > hh$modelStruct$corStruct[1] > [1] -1.308580 > > hh$modelStruct$varStruct[1] > [1] -0.03124255 > > I presume there is a way to calculate the correlation and > variance function coefficients using these values. > > Could you tell me how to access those values (without using > the intervals function) or better still how to calculate the > values from the last output values. > > Kind regards > Pryseley > > > > __________________________________________________ > > >
OK, in the future it might be helpful to note what you tried and what error messages you received when you worked with the syntax provided. Why did VarCorr() not work? In general, there seems to be a larger probelm with your model as Doug Bates noted. I would also suggest that you go about this another way. Instead of using lme(), switch to lmer and then use the MCMCsamp() function to investigate the parameters of the model. To see what can be accesed from the fitted lmer object use str(model) or use the other extractor functions such as VarCorr when needed. ________________________________ From: Pryseley Assam [mailto:assampryseley@yahoo.com] Sent: Thursday, June 01, 2006 9:38 AM To: Doran, Harold Cc: r-help@stat.math.ethz.ch Subject: RE: [R] Help: lme Good day, Yeah i tried most of the suggestions and still had the same problem. Some people also suggested that i supplied a data set so they could verify what i am saying. That is why i am still asking the same question with more details as required. My main focus now is to calculate the values in the "unaccessible"-printed output from the accessible ones as mentioned towards the end of my latest mail. Kind regards Pryseley "Doran, Harold" <HDoran@air.org> wrote: Pryseley: You asked this question last week and received answers to that question along with other suggestions from Doug Bates and myself. Is there some reason the post by Andrew Robinson is not working? Harold > -----Original Message----- > From: r-help-bounces@stat.math.ethz.ch > [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Pryseley Assam > Sent: Thursday, June 01, 2006 6:25 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Help: lme > > Good day R-Users, > > I have a problem accessing some values in the output from > the summary of an lme fit. > > > The structure of my data is as shown below (I have attached a > copy of the full data). > > > id trials endp Z.sas ST > 1 1 -1 -1 42.42884 > 1 1 1 -1 48.12007 > 2 1 -1 -1 43.42878 > 2 1 1 -1 46.82817 > 3 1 -1 -1 45.56736 > ........................................... > 598 10 -1 1 49.59715 > 598 10 1 1 55.46324 > 599 10 -1 1 46.80873 > 599 10 1 1 53.52223 > 600 10 -1 1 48.58257 > 600 10 1 1 56.78674 > > I used the following code to fit my model of interest: > > ggg <- lme (ST~ -1 + as.factor(endp):Z.sas + > as.factor(endp), data=dat4a, > random=~-1 + as.factor(endp) + > as.factor(endp):Z.sas|as.factor(trials), > correlation = > corSymm(form=~1|as.factor(trials)/as.factor(id)), > weights=varIdent(form=~1|endp)) > > hh <- summary(ggg) > hh > > Below is the following part of the output of interest I > wish to access: > > Correlation Structure: General > Formula: ~1 | as.factor(trials)/as.factor(id) Parameter estimate(s): > Correlation: > 1 > 2 0.785 > Variance function: > Structure: Different standard deviations per stratum > Formula: ~1 | endp > Parameter estimates: > -1 1 > 1.0000000 0.9692405 > > I wish to access the value of the correlation (0.785) and > the vector of the variance function estimates (1, 0.969). I > know these can be done through the intervals function, but > sometimes when the estimated Hessian matrix is not positive > definite or something like that (i am not quite sure), the > intervals function delivers an error message. > > Thus, i will like to ask if there is another way to access > these values. I tried using the following code: > > hh$modelStruct$corStruct[1] > hh$modelStruct$varStruct[1] > > Rather the output was: > > > hh$modelStruct$corStruct[1] > [1] -1.308580 > > hh$modelStruct$varStruct[1] > [1] -0.03124255 > > I presume there is a way to calculate the correlation and > variance function coefficients using these values. > > Could you tell me how to access those values (without using > the intervals function) or better still how to calculate the > values from the last output values. > > Kind regards > Pryseley > > > > __________________________________________________ > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com [[alternative HTML version deleted]]
Apparently Analagous Threads
- Query: lme output
- trouble with extraction/interpretation of variance structure para meters from a model built using gnls and varConstPower
- lme and gls : accessing values from correlation structure and variance functions
- How to extract parameter estimates of variance function from lme fit
- query: lme