search for: newdata

Displaying 20 results from an estimated 1060 matches for "newdata".

2007 Jan 11
1
Matching on multiple columns
...ect but it would not allow me to deselect (or exclude). Look at how I got around the problem. It is inelegant. Have a missed a more direct function? x<-seq(from=1,to=10) y <-rep(1:2,5) data<-data.frame(cbind(x,y)) x<-seq(from=1,to=10) y <-rep(1:5,2) data1<-data.frame(cbind(x,y)) newdata<-rbind(data,data1) newdata[10,2] <- 3 exclude<-newdata[18:20,] #This is a simulation of real life problem #We now have two dataframes. Newdata is the data set from an experiment. In real #life it has an additional 9 columns of data #exclude is a dataframe that was manually created after di...
2010 Jul 23
2
decimal seperator
...;,"Gao","Ansongo","Kidal","Tessalit","BkoCommI","BkoCommIII","BkoCommV") size <- list(2.91,2.36,5.09,3.21,2.27,4.09,2.31,2.76,1.2,2.03,3.06,0.53,1.43,1.83,1,0.93,0,4.01,4.13,3.47) site_size <- data.frame(cbind(sites, size)) newdata <- (sapply(subset(site_size, select=c("size")), as.numeric)) rownames(newdata) <- site_size$sites library(grid) plot(newdata, ylab =" ", xlab= " " , axes = FALSE)#, type="h", lwd=16) points(newdata, cex = 10, col = topo.colors(20), bg=topo.colors(20),...
2008 Apr 14
2
Bug in ci.plot(HH Package) (PR#11163)
...f.level=conf.level) I think the correct is "level=conf.level". Is that right? --- ci.plot source code --- "ci.plot" <- function(lm.object, ...) UseMethod("ci.plot") "ci.plot.lm" <- function(lm.object, xlim=range(data[, x.name]), newdata, conf.level=.95, data=model.frame(lm.object), newfit, ylim=range(newfit$pi.fit), pch=16, main.cex=1, main=list(paste(100*conf.level, "% confidence and prediction intervals for ", substitute(lm.object), se...
2010 Mar 08
1
confused by classes and methods.
...beg = "numeric", current = "numeric", avg = "numeric", obs = "vector" ) ) and the following function updateStatistic <- function(statistic, newData){ statistic@obs = c(statistic@obs, newData) statistic@max = max(newData, statistic@max, na.rm=T) statistic@min = min(newData, statistic@min, na.rm=T) statistic@avg = mean(statistic@obs) statistic@current = newData if(length(statistic@obs)==1 || is.na(statistic@beg)){...
2013 Sep 30
1
predictions in nlme without fixed covariantes
Dear all, predict.lme() throws an error when the fixed part consists of only an intercept and using newdata. See the reproducible example below. I've tracked the error down to asOneFormula() which returns in this case NULL instead of a formula. Changing NULL instead of ~1 in that function (see below) solves the problem in the case of an intercept only model (m1). It does not solve the problem in case...
2011 Jan 28
6
User error in calling predict/model.frame
I want to predict values from an existing lm (linear model, e.g. lm.obj) result in R using a new set of predictor variables (e.g. newdata). However, it seems that because my linear models was made by calling scale() on the target predictor that predict exits with an error, "Error in scale(xxA, center = 9.7846094491829, scale = 0.959413568556403) : object 'xxA' not found". By debugging predict, I can see that the e...
2006 Mar 25
1
There were 25 warnings (use warnings() to see them)
...251:13500,9]) > t pred 0 1 0 42 40 1 12 22 > classAgreement(t) but I get the warning. The warnings run like this: > warnings() Warning messages: 1: number of rows of result is not a multiple of vector length (arg 2) in: cbind(1, 1:N, predict(object$mtrees[[i]], newdata, type = "class")) 2: number of rows of result is not a multiple of vector length (arg 2) in: cbind(1, 1:N, predict(object$mtrees[[i]], newdata, type = "class")) 3: number of rows of result is not a multiple of vector length (arg 2) in: cbind(1, 1:N, predict(obj...
2011 Nov 15
3
how to indice the column in the data.frame
hi R,users Now I read a data from a txt file newdata<-read.table("1.txt") in the 1.txt ,there are several column shown as below 1 3 4 5 2 3 5 6 4 5 6 7 so when I want analysis the second column anadata<-newdata$V2 but my question I can not use some certain variable to indice the column? e.g cmn=2 anadata<-newdata$Vcmn how can I f...
2008 Dec 16
1
Prediction intervals for zero inflated Poisson regression
...What I tried until now is to use bootstrap to estimate these intervals. Any comments on the code are welcome. The data and the model are based on the examples in zeroinfl(). #aproximate prediction intervals with Poisson regression fm_pois <- glm(art ~ fem, data = bioChemists, family = poisson) newdata <- na.omit(unique(bioChemists[, "fem", drop = FALSE])) prediction <- predict(fm_pois, newdata = newdata, se.fit = TRUE) ci <- data.frame(exp(prediction$fit + matrix(prediction$se.fit, ncol = 1) %*% c(-1.96, 1.96))) newdata$fit <- exp(prediction$fit) newdata <- cbind(newdata...
2011 Apr 26
2
Wish R Core had a standard format (or generic function) for "newdata" objects
Is anybody working on a way to standardize the creation of "newdata" objects for predict methods? When using predict, I find it difficult/tedious to create newdata data frames when there are many variables. It is necessary to set all variables at the mean/mode/median, and then for some variables of interest, one has to insert values for which predictions are...
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 When i checked help(predict.lm) I found this: "Variables are first looked for in newdata and...
2007 Jan 26
1
bootstrap bca confidence intervals for large number of statistics in one model; library("boot")
...Below is a toy example of how to do this using the "boot" library. We obtain BCA CIs for all three regression parameters and for the fitted values at 50 levels of the predictor. set.seed(1234567) x<-runif(150) y<-2/3 + pi * x^2 + runif(length(x))/2 plot(x,y) DAT<-data.frame(x,y) NEWDATA<-data.frame(x=seq(min(x), max(x), length=50)) library('boot') myfn<-function(data, whichrows) { TheseData<-data[whichrows,] thisLM<-lm( y~poly(x,2), data=TheseData) thisFit<-predict(thisLM, newdata=NEWDATA) c( coef(summary(thisLM))[,"Estimate"] , thisFit) }...
2018 Apr 25
0
Zero errors : Bug in my R code ?
...brary(quantreg) library(RobPer) library(hbrfit) library("devtools") library("DMwR") bmi=c(23,43,12,1,23,4,3,4,5,5,6,5,5,34,67,87,32,12,23,19) glucose=c(98,34,21,13,2,43,16,43,28,93,11,14,16,43,23,65,42,16,54,32) crp=c(56,34,42,32,1,2,54,47,67,65,38,95,45,76,67,87,35,41,34,54) newdata=data.frame(bmi,glucose,crp) ? reg1 <- lm( crp ~ bmi+glucose,data=newdata) DMwR::regr.eval(newdata$crp,reg1$fitted.values) reg <- lmrob( crp ~ bmi+glucose,data=newdata) DMwR::regr.eval(newdata$crp,reg$fitted.values) Huber <- rlm( crp ~ bmi+glucose,data=newdata) DMwR::regr.eval(newdata$crp...
2007 Aug 22
3
tackle memory insufficiency for large dataset using save() & load()??
...Mean : 14.16 3rd Qu.: 750.3 3rd Qu.: 17.00 Max. :1000.0 Max. :192.00 NA's :118.00 > save (d, file="compact_d.Rdata", ascii=FALSE) > > newdata <- load ("compact_d.Rdata") > > summary(newdata) Length Class Mode 1 character character > attach(newdata) Error in attach(newdata) : file 'd' not found > is.data.frame (newdata) [1] FALSE > is.list (newdata) [1] FALSE > is.matrix (newda...
2006 May 19
1
How to use lm.predict to obtain fitted values?
...ample 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 = predict.lm(model,data.frame(x=newData)); Warning message: 'newdata' had 6 rows but variable(s) found have 51 rows. > pred = predict.lm(model,data.frame(newData)); Warning message: 'newdata' had 6 rows but variable(s) found have 51 rows. y is a v...
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 a solution of this problem. best r...
2004 Nov 05
3
Resources for optimizing code
...nction which can do the above better than mine. My code is pasted below. Thanks so much, Janet # asst is a binary vector of length= nrow(DATAFRAME). # 1= observations you want to keep. 0= observation to get rid of. remove.xtra.f <-function(asst, DATAFRAME) { n<-sum(asst, na.rm=T) newdata<-matrix(nrow=n, ncol=ncol(DATAFRAME)) j<-1 for(i in 1:length(data)) { if (asst[i]==1) { newdata[j,]<-DATAFRAME[i,] j<-j+1 } } newdata.f<-as.data.frame(newdata) names(newdata.f)<-names(DATAFRAME) return(newdata.f) } -- Janet Rosenbaum...
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 columns of 'x' This doesn't happen if M doesn't have coloumn names. For instance: > M <- matrix(rnorm(30), ncol = 3) > mod <- prcomp(M[-1,]) > predict(mod, newdata = M[1,, drop =...
2013 Jun 25
1
censor=FALSE and id options in survfit.coxph
...(z, y, e)~x, data=dat) summary(mod) # create prediction dataset with 3 individuals with # x = 0 on (0,2) # x = 1 on (0,2) # x = 0 on (0,1) and x = 1 on (1,2) datnew <- data.frame(x=c(0,1,0,1), z=c(0,0,0,1), y=c(2,2,1,2), e=rep(0,4), id=c(1,2,3,3)) datnew # as expected modsf1 <- survfit(mod, newdata=datnew, id=id) modsf1 # not as expected modsf2 <- survfit(mod, newdata=datnew, id=id, censor=FALSE) modsf2 # for comparison modsf3 <- survfit(mod, newdata=datnew[1:2,]) modsf3 # appears to work when individual=FALSE (id not specified) modsf4 <- survfit(mod, newdata=datnew[1:2,], censor...
2018 Jul 20
2
Model formulas with explicit references
...ncerns models where variables are explicitly referenced (or is it "dereferenced"?), such as: cars.lm <- lm(mtcars[[1]] ~ factor(mtcars$cyl) + mtcars[["disp"]]) I have found that it is not possible to predict such models with new data. For example: > predict(cars.lm, newdata = mtcars[1:5, ) 1 2 3 4 5 6 7 8 9 10 20.37954 20.37954 26.58543 17.70329 14.91157 18.60448 14.91157 25.52859 25.68971 20.17199 11 12 13 14 15 16 17 18 19 20 20.17199 1...