Dear Splus users,
I am a beginner Splus user with
the following problem which I have not been able to resolve, after many, many
attempts. I would be really
grateful for anyone?s advice as to how to clear this up. I believe the problem is not related
only to lme analysis, although it happens to have come up in my program
involving lme analysis. I am using windows version 6.0
Professional release 1.
OBJECTIVE:
----------------
I want to use the lme model
from one dataset (data1), and predict the fit of the model to the response
variable (crtD0) in a second dataset (data2). Note: All variables are named
identically in the two files.
I wish to then calculate
the correlation between (1) the predictions of crtD0 made from the new dataset,
and (2) the true response variable (crtD0) in that
dataset.
PROBLEM:
-------------
I have not managed to explicitly
identify these predictions so that I can ultimately calculate the correlation
mentioned above. My best attempt at
doing so is included in the code below, together with error messages and other
potentially useful output. I wonder
if the problem is related to the fact that the predicted data are in the form of
a ?list? rather than a ?vector?.
My code is as
follows:
--------------------------
YD0 <- lme(crtD0~ lnLakStr+
LkCond+Vel+VelSq, random = pdIdent(~Year-1), data=""
na.action="">
OutA<- predict(YD0, data2,
na.action="" asList=TRUE)
fixp <- cor(data2$crtD0,OutA$fit,
na.method=?omit?) #NOTE: this
command line
# does not work. It generates the error shown
below.
ERROR MESSAGES AND DETAILS
-----------------------------------------------
Problem in cor(data2$crtD0, OutA$fit, na.method =
"..: x and y must have the same number of observations
Use traceback() to see the call
stack
>
traceback()
6: eval(action,
sys.parent())
5: doErrorAction("Problem in cor(data2$crtD0,
OutA$fit, na.method = \"..: x and
y must have the same number of
observations",
4: stop("x and y must have the same number of
observations")
3: cor(data2$crtD0, OutA$fit, na.method =
"omit")
2: eval(_expression_(fixp <- cor(data2$crtD0,
OutA$fit, na.method = "omit")))
1: Message: Problem in cor(data2$crtD0, OutA$fit,
na.method = "..: x and y must ha
ve the same number of
observations
>
data2$crtD0
[1] 0.0000000 0.0000000 0.0000000
1.4640291 0.6064721 1.0236825 0.9320548
[8] 0.5848164 0.6670904 0.0000000
1.0879557 0.9025623 0.5908131 0.8790737
[15] 1.0649321 1.2066245 0.8649947 1.1338901
0.6556256 0.2102818 1.0689819
[22] 0.7800671
> OutA$fit
NULL
> OutA
$"1":
166 177
44
86
142
91
61
141
0.1413825 0.3752559 0.6503886 1.416931
0.614871 0.6193152 0.696556 0.625847
199 117 62
68
93
58
200
1.038019 0.4726644 0.6630099 0.5185122
0.5689107 0.6471098 0.9757536
65 124
67
104
25
40
138
0.701244 0.5570682 0.5843057 0.7628579
0.9623016 0.7777507 0.5756814
attr(,
"label"):
[1] "Predicted values"
>
is.list(OutA)
[1] T
Thank you very
much for any help you can give me with
this.
Sincerely,
Cynthia