Displaying 20 results from an estimated 10000 matches similar to: "predict function (PR#2958)"
2006 May 27
1
Recommended package nlme: bug in predict.lme when an independent variable is a polynomial (PR#8905)
Full_Name: Renaud Lancelot
Version: Version 2.3.0 (2006-04-24)
OS: MS Windows XP Pro SP2
Submission from: (NULL) (82.239.219.108)
I think there is a bug in predict.lme, when a polynomial generated by poly() is
used as an explanatory variable, and a new data.frame is used for predictions. I
guess this is related to * not * using, for predictions, the coefs used in
constructing the orthogonal
2010 Jan 18
2
Predict polynomial problem
I have a function that fits polynomial models for the orders in n:
lmn <- function(d,n){
models=list()
for(i in n){
models[[i]]=lm(y~poly(x,i),data=d)
}
return(models)
}
My data is:
> d=data.frame(x=1:10,y=runif(10))
So first just do it for a cubic:
> mmn = lmn(d,3)
> predict(mmn[[3]])
1 2 3 4 5 6 7 8
2002 Jan 12
2
Bug in predict(newdata=x) with poly() (PR#1258)
Bug in predict.lm & poly
The predict function doesn't work when used with poly and newdata.
For example, I'd expect the following code to work, and plot a fitted
cubic to the nearly straight line:
x <- 1:10
y <- x + rnorm(10)/100
plot(x,y)
fit <- lm(y ~ poly(x,3))
newx <- seq(1,10,len=100)
lines(newx,predict(fit,newdata=data.frame(x=newx)))
However, the plotted
2003 Oct 27
2
problem using do.call and substitute for predict.glm using poly()
Hi
I am having a particular problem with some glm models I am running. I
have been adapting code from Bill Venables 'Programmers niche' in RNews
Vol 2/2 to fit ca. 1000 glm models to a combination of species 0/1 data
(as Y) and related physicochemical data (X), to automate the process of
fitting this many models. I have successfully managed to fit all the
models and have stored the
2015 Apr 30
2
predict nlme
Estimado Oliver Nuñez
Envío un ejemplo reproducible.
Javier Marcuzzi
# de donde tomo datos, y tiene el modelo (en el pdf)
library(MCMCglmm)
# librería con las funciónes que voy a usar
library(nlme)
datos0<-ChickWeight
# creo algunos datos que agrego a los origonales
Factor<-as.numeric(datos0$Chick)
Factor[Factor > 0 & Factor <= 10] <- 'A'
Factor[Factor > 10
2015 Apr 30
2
predict nlme
Estimados
Tengo un error que me desconcierta, es un código que simplifiqué de otro trabajo donde no hay problemas, sin embargo me da un error.
Una diferencia es que en mi otro trabajo uso spline y ahora polinomio, este es de segundo grado y se encuentra tanto en efectos fijos como aleatorios, el modelo es correcto, corre con MCMCglmm pero no con nlme.
grid <- expand.grid(Tiempo=4:6,
2010 Jul 21
3
Help me with prediction in linear model
Hi R-community,
I have the code as follows,i Fitted model as follows
lbeer<-log(beer_monthly)
t<-seq(1956,1995.2,length=length(beer_monthly)) #beer_monthly contains 400+
entries
t2=t^2
beer_fit_parabola=lm(lbeer~t+t2)
Below is not working for me.
Please help me in preparing the new data set for the below prediction
2007 Jan 26
1
bootstrap bca confidence intervals for large number of statistics in one model; library("boot")
Sometimes one might like to obtain pointwise bootstrap bias-corrected,
accelerated (BCA) confidence intervals for a large number of statistics
computed from a single dataset. For instance, one might like to get
(so as to plot graphically) bootstrap confidence bands for the fitted
values in a regression model.
(Example: Chiu S et al., Early Acceleration of Head Circumference in
Children with
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 <-
2005 Aug 15
1
error in predict glm (new levels cause problems)
Dear R-helpers,
I try to perform glm's with negative binomial distributed data.
So I use the MASS library and the commands:
model_1 = glm.nb(response ~ y1 + y2 + ...+ yi, data = data.frame)
and
predict(model_1, newdata = data.frame)
So far, I think everything should be ok.
But when I want to perform a glm with a subset of the data,
I run into an error message as soon as I want to predict
2003 Aug 07
2
plotmath under windows (PR#3672)
Full_Name: Murray H Smith
Version: 1.7.1
OS: Windows2000
Submission from: (NULL) (202.36.29.1)
This alleged bug is Windows specific and occurs when using Windows metafile
plots.
The problem does not occur in a Linux version.
It does not occur in the pt rintout when a graphic is saved to a postscript file
under Windows.
The problem came to light when using plotmath to label a plot with
2006 Jun 27
1
order() (PR#9039)
Full_Name: Murray Smith
Version: 2.2.1
OS: Windows XP
Submission from: (NULL) (202.36.29.1)
order() will not allow a complex vector for its first argument. This contrasts
with sort() which will happily sort a complex vector.
While this may not be regarded as a bug by some, it is annoying for anyone who
makes frequent use of complex numbers.
The problem occured in the Windows version 2.2.1 of
2007 Jan 25
1
'Fitting' a model at predefined points
Hi,
I have a linear model ("mod1 <- lm(V3~V1+V2) and I would like to get the
model's prediction at values of V1 and V2 not included in the original
sample.
samp <- read.table("data.dat",nrows=100)
attach(samp)
out.poly <- lm(V3 ~ V1 + V2)
If I try to use out.poly to predict values for the function I run into
problems. It seems that it isn't possible to use a new
2006 Nov 09
1
predict.lm "variables found" question
hello,
I'm trying to predict some values based on a linear regression model.
I've created the model using one dataframe, and have the prediction
values in a second data frame (call it newdata). There are 56 rows in
the dataframe used to create the model and 15 in newdata.
I ran predict(model1, newdata) and get the warning: 'newdata' had 15
rows but variable(s) found have 56 rows
2011 Mar 20
4
predicting values from multiple regression
Hey List,
I did a multiple regression and my final model looks as follows:
model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2))
Now I tried to predict the values for calP from this model using the
following function:
xv<-seq(0,89,by=1)
yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv))
The predicted values are however strange. Now I do not know weather
just the model does not fit
2005 Nov 18
1
pr[in]comp: predict single observation when data has colnames (PR#8324)
To my knowledge, this has not been reported previously, and doesn't
seem to have been changed in R-devel or R-patched.
If M is a matrix with coloumn names, and
mod <- prcomp(M) # or princomp
then predicting a single observation (row) with predict() gives the
error
Error in scale.default(newdata, object$center, object$scale) :
length of 'center' must equal the number of
2006 May 19
1
How to use lm.predict to obtain fitted values?
I am writing a function to assess the out of sample predictive capabilities
of a time series regression model. However lm.predict isn't behaving as I
expect it to. What I am trying to do is give it a set of explanatory
variables and have it give me a single predicted value using the lm fitted
model.
> model = lm(y~x)
> newdata=matrix(1,1,6)
> pred =
2006 May 30
0
(PR#8905) Recommended package nlme: bug in predict.lme when an independent variable is a polynomial
Many thanks for your very useful comments and suggestions.
Renaud
2006/5/30, Prof Brian Ripley <ripley at stats.ox.ac.uk>:
> On Tue, 30 May 2006, Prof Brian Ripley wrote:
>
> > This is not really a bug. See
> >
> > http://developer.r-project.org/model-fitting-functions.txt
> >
> > for how this is handled in other packages. All model-fitting in R used =
2010 Dec 25
2
predict.lrm vs. predict.glm (with newdata)
Hi all
I have run into a case where I don't understand why predict.lrm and
predict.glm don't yield the same results. My data look like this:
set.seed(1)
library(Design); ilogit <- function(x) { 1/(1+exp(-x)) }
ORDER <- factor(sample(c("mc-sc", "sc-mc"), 403, TRUE))
CONJ <- factor(sample(c("als", "bevor", "nachdem",
2010 Jan 16
2
predict.glm
Hi,
See below I reply your message for <https://stat.ethz.ch/pipermail/r-help/2008-April/160966.html>[R] predict.glm & newdata posted on Fri Apr 4 21:02:24 CEST 2008
You say it ##works fine but it does not: if you look at the length of yhat2, you will find 100 and not 200 as expected. In fact predict(reg1, data=x2) gives the same results as predict(reg1).
So I am still looking for