Displaying 20 results from an estimated 76 matches for "predvar".
Did you mean:
predvars
2003 Mar 26
2
predict (PR#2685)
There is a bug in `predict' whereby the order of variables sometimes gets
re-arranged compared to the original fit, and then disaster results.
Specifically, the 'variables' and 'predvars' attributes of a 'terms' object
get out of synch. This only happens when the terms in the original formula
get re-ordered during fitting:
test> scrunge.data_ data.frame( contin=1:10, discrete=factor( rep( c( 'cat',
'dog'), 5)), resp=runif( 10))
test> lm.ok_ lm( r...
2012 Jun 05
1
model.frame and predvars
I was looking at how the model.frame method for lm works and comparing
it to my own for coxph.
The big difference is that I try to retain xlevels and predvars
information for a new model frame, and lm does not.
I use a call to model.frame in predict.coxph, which is why I went that
route, but never noted the difference till now (preparing for my course
in Nashville).
Could someone shed light on the rationale for non-preservation?
Terry T.
Simple e...
2018 Mar 20
0
Struggling to compute marginal effects !
...; c("Not_reliable_at_all","Less_reliable","Somehow_reliable","Very reliable"))
>
> First model
> object1 <- polr(Inc ~ Adopt ,Data,Hess = T,method = "logistic")
>
> Marginal effect for object1:
> ocME(object1)
> Error in eval(predvars, data, env) :
> numeric 'envir' arg not of length one
>
> Second model
> object2 <- polr(Inc ~ Adopt + Training ,Data,Hess = T,method = "logistic" )
>
> Marginal effect for object2:
> ocME(object2)
> effect.Not_reliable_at_all effect.Less_reliable eff...
2012 Jan 05
1
delete.response leaves response in attribute dataClasses
...Here's the behavior I assert is a bug:
The output from delete.response on a terms object alters the formula
by removing the dependent variable. It removes the response from the
"variables" attribute and it changes the response attribute from 1 to
0. The response is removed from "predvars"
But it leaves the name of the dependent variable first in the in
"dataClasses". It caused an unexpected behavior in my code, so (as
usual) the bug may be mine, but in my heart, I believe it belongs to
delete.response.
To illustrate, here's a terms object from a regression....
2018 Apr 27
5
predict.glm returns different results for the same model
Hi all,
Very surprising (to me!) and mystifying result from predict.glm(): the
predictions vary depending on whether or not I use ns() or
splines::ns(). Reprex follows:
library(splines)
set.seed(12345)
dat <- data.frame(claim = rbinom(1000, 1, 0.5))
mns <- c(3.4, 3.6)
sds <- c(0.24, 0.35)
dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd =
sds[dat$claim + 1]))
dat <-
2018 Mar 19
4
Struggling to compute marginal effects !
Dear Oscar,
and any other R-project person,
Can you please help me to figure out the meaning of the following error
message in red ?
Error in eval(predvars, data, env) :
numeric 'envir' arg not of length one
I computed ordered logit models using 'polr' in R (I just followed the
guidance a handout I found on princeton.edu about logit, probit and
multinomial logit models) . The summary results are obtained without any
problem. *Howev...
2011 Apr 19
1
How to Extract Information from SIMEX Output
....labels")= chr "x"
.. .. .. ..- attr(*, "order")= int 1
.. .. .. ..- attr(*, "intercept")= int 1
.. .. .. ..- attr(*, "response")= int 1
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. .. .. ..- attr(*, "predvars")= language list(y, x)
.. .. .. ..- attr(*, "dataClasses")= Named chr [1:2] "factor" "numeric"
.. .. .. .. ..- attr(*, "names")= chr [1:2] "y" "x"
..$ x : num [1:1615, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
.. ..- attr(*...
2009 Jul 29
3
predict
...e to predict value in
different points. I have tried to use predict function but it doesn't work.
I have used predict function like this:
newdata<-seq(from=0.1, to=0.32,by=0.02)
data<-predict(fm,newdata)
where fm is a regression model. The predict function return me that:
Error in eval(predvars, data, env) : numeric argument 'envir' doesn't have
unitary length
where is the error?
--
View this message in context: http://www.nabble.com/predict-tp24719362p24719362.html
Sent from the R help mailing list archive at Nabble.com.
2017 Aug 05
2
Ussing assign
...data.frame(x=rnorm(100),y=rnorm(100))
}
Now, if I want to do create the five models, I do not know how to set this created data.frames
I have tried:
for (i in 1:5){
assign(paste0("model",i),lm(y~x,data=paste0("variable",i)))
}
but it does not working.
Error in eval(predvars, data, env) :
invalid 'envir' argument of type 'character'
Can you please help me to find the correct way?
Thanks!
Jes?s
[[alternative HTML version deleted]]
2010 Jul 21
2
Variance of the prediction in the linear regression model (Theory and programming)
Hi, folks,
Here are the codes:
##############
y=1:10
x=c(1:9,1)
lin=lm(log(y)~x) ### log(y) is following Normal distribution
x=5:14
prediction=predict(lin,newdata=x) ##prediction=predict(lin)
###############
1. The codes do not work, and give the error message: Error in
eval(predvars, data, env) :
numeric 'envir' arg not of length one. But if I use the code after the
pound sign, it works. I mean the name of the newdata is x, why it does not
work though?
2. Because the prediction is conducted for log(y). I need to get the
expected value of y, which is LN distributi...
2010 Nov 11
3
Evaluation puzzle
...number, or 0 to exit
1: tfun(tdata)
2: survexp.test(zed ~ 1, data = mydata)
3: eval(m, parent.frame())
4: eval(expr, envir, enclos)
5: model.frame(formula = "zed ~ 1+age+sex+year", data = mydata)
6: model.frame.default(formula = "zed ~ 1+age+sex+year", data = mydata)
7: eval(predvars, data, env)
8: eval(expr, envir, enclos)
Selection: 2
Called from: model.frame.default(formula = "zed ~ 1+age+sex+year", data = mydata)
Why does selecting "2" result in going to frame "6"?
Terry Therneau
2018 Aug 05
2
MASS::boxcox "object not found"
Hi there,
I wrote a function that wraps MASS::boxcox as:
bc <- function(vec) {
lam <- boxcox(lm(vec ~ 1))
lam <- lam$x[which.max(lam$y)]
(vec^lam - 1)/lam
}
When I invoke it as:
> x <- runif(20)
> bc(x)
Error in eval(predvars, data, env) : object 'vec' not found
I have googled, and rewrote the above function as:
bc <- function(vec) {
dat <<- data.frame(vec = vec)
lam <- boxcox(lm(vec ~ 1, dat))
lam <- lam$x[which.max(lam$y)]
rm(dat, envir = .GlobalEnv)
(vec^lam - 1)/lam
}
It wor...
2018 Aug 05
2
MASS::boxcox "object not found"
Hi there,
I wrote a function that wraps MASS::boxcox as:
bc <- function(vec) {
lam <- boxcox(lm(vec ~ 1))
lam <- lam$x[which.max(lam$y)]
(vec^lam - 1)/lam
}
When I invoke it as:
> x <- runif(20)
> bc(x)
Error in eval(predvars, data, env) : object 'vec' not found
I have googled, and rewrote the above function as:
bc <- function(vec) {
dat <<- data.frame(vec = vec)
lam <- boxcox(lm(vec ~ 1, dat))
lam <- lam$x[which.max(lam$y)]
rm(dat, envir = .GlobalEnv)
(vec^lam - 1)/lam
}
It wor...
2011 Jan 28
6
User error in calling predict/model.frame
...rror, "Error in scale(xxA, center = 9.7846094491829, scale =
0.959413568556403) : object 'xxA' not found". By debugging predict, I
can see that the error occurs in a call to model.frame. By debugging
model frame I can see the error occurs with this command: variables
<- eval(predvars, data, env); it seems likely that the error is
because predvars looks like this:
list(scale(xxA, center = 10.2058714830537, scale = 0.984627257169526),
scale(xxB, center = 20.4491690881149, scale = 1.13765718273923))
An example case:
dat <- data.frame(xxA = rnorm(20,10), xxB = rn...
2018 Apr 27
0
predict.glm returns different results for the same model
...96 4.06743266
> unname(predict(m2, newdata = newdf))
> #> [1] 0.5194712 -0.5666554 -0.1731268 2.8134844 3.9295814
>
> Is this a bug?
The two objects m1 and m2 differ more than they should, so this looks
like a problem in glm, not just in predict.glm.
> attr(m1$terms, "predvars")
list(claim, ns(wind, knots = c(25.4756277492997, 30.2270250736796,
35.4093171222502, 43.038645381669), Boundary.knots = c(12.9423820390783,
108.071583734075), intercept = FALSE))
> attr(m2$terms, "predvars")
list(claim, splines::ns(wind, df = 5))
This appears to be due to a...
2018 Jan 10
1
svm --- type~.
Dear All: Just fixed where is the problem
I am trying to use the R function "svm" with "type~." , but I got the
following error message
SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, *type='C-classification'*,
kernel='linear',scale=FALSE)
*Error in eval(predvars, data, env) : object 'type' not found*
I am wondering if I should install a specific R package(s).
*Here is my codes:*
feature.x1 <- c(0.25,0.5,1,1,1.5,2,2.25,2.5,2,1,3, 5,3.75,
1,3.5,4,4,5,5.5,6,6,6.5)
length(feature.x1)
feature.x2 <- c(2,3.5,1,2.5,1.75,2,1.75,1.5,2.5,1...
2010 May 05
1
puzzles with assign()
...me <- paste(TimePt,'df',sep='.') # invent a relevant name/symbol as a
character string.
assign(temp.name,IGF.df[IGF.df$TPt==TimePt,]) # this works. The relevant
variable is now a data frame
lm(b ~ Strain+BWt+PWt+PanPix, data=temp.name)) # this gives an error, namely
Error in eval(predvars, data, env) : invalid 'envir' argument
I think it's obvious what I want to achieve, but how is it done? I tried
data=as.name(temp.name)
but that also didn't work. I can't find anything relevant in "Introduction
to R".
Here is a secondary question:
While trying to un...
2010 Jan 16
2
predict.glm
...x2=x1*2
r.norm2=rnorm(200,0,20)
x2=r.norm2+x2
reg1=glm(y1~x1,binomial)
yhat=predict(reg1) ##prediction works fine
yhat=predict(reg1,newdata=x2) ##gives error message because of "newdata"
>Error in eval(predvars, data, env) :
numeric 'envir' arg not of length one
yhat=predict(reg1,data=x2) ##works fine
##using offset
ofst=rep(0.5,100)
reg1=glm(y1~x1,binomial,offset=ofst)
yhat=predict(reg1)
yhat1=predict(reg1,newdat...
2018 Jan 10
1
svm
Dear All:
I am trying to use the R function "svm" with "type =C-classification" ,
but I got the following error message
SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, *type='C-classification'*,
kernel='linear',scale=FALSE)
*Error in eval(predvars, data, env) : object 'type' not found*
I am wondering if I should install a specific R package(s).
*Here is my codes:*
feature.x1 <- c(0.25,0.5,1,1,1.5,2,2.25,2.5,2,1,3, 5,3.75,
1,3.5,4,4,5,5.5,6,6,6.5)
length(feature.x1)
feature.x2 <- c(2,3.5,1,2.5,1.75,2,1.75,1.5,2.5,1...
2017 Aug 05
0
Ussing assign
...five models, I do not know how to set this created data.frames
>
>
> I have tried:
>
>
> for (i in 1:5){
>
>
> assign(paste0("model",i),lm(y~x,data=paste0("variable",i)))
>
>
> }
>
>
> but it does not working.
>
> Error in eval(predvars, data, env) :
> invalid 'envir' argument of type 'character'
>
>
> Can you please help me to find the correct way?
>
>
> Thanks!
> Jes?s
>
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> _________...