search for: nmatrix

Displaying 19 results from an estimated 19 matches for "nmatrix".

Did you mean: matrix
2009 Oct 08
0
predict.lm() out-of-sample predictions - problem with data classes
...g newdata, which is a data.frame with all variables being "numeric", as str() shows, R tells me the following: ar1.xpred.test.pred <- predict(ar1.xpred.fitted, regdata.test, se.fit = FALSE) Fehler: variable 'lag(ret1)' was fitted with type "numeric" but type "nmatrix.1" was supplied Zus?tzlich: Warnmeldung: 'newdata' had 23 rows but variable(s) found have 89 rows Estimating a model from the test-data and examining, the resulting lm-object I found out that the "data classes" switched to "nmatrix.1" - while they were "nume...
2008 Feb 26
1
predict.rpart question
...unique(rownames(rpartModel$splits)); When later I apply the rpart model to predict the new data I strip the input data from unneccessary columns and only use X columns that exist in colnamesUsed. Unfortunately I get error message like this Error: variable 'X' was fitted with type "nmatrix.3522" but type "nmatrix.19" was supplied The error message is correct. In the documentation it clearly specifies that the predictors referred to in the right side of formula (object) must be present by name in newdata, but I wonder why, if they are not used? Thanks DK ________...
2012 Mar 06
1
PLS Error message
Hi, I work with hyperspectral remote sensing data and I try to built a pls model with this data. I already built the model but if I try to calculate the RMSEP and R2 with a test data set I get the following error message: Error: variable 'subX' was fitted with type "nmatrix.501" but type "nmatrix.73" was supplied The problem is that I don't get the message for the pls models. Thank you very much for your help. /Thomas -- *^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^* Thomas Möckel, PhD student Department of Earth and Ecosystem Science Lund U...
2010 Jan 18
2
Predict polynomial problem
...7 8 0.6228353 0.5752811 0.5319524 0.4957381 0.4695269 0.4562077 0.4586691 0.4798001 9 10 0.5224893 0.5896255 - thats the same as last time. Extrapolate? > predict(mmn[[3]],newdata=data.frame(x=c(9,10,11))) Error: variable 'poly(x, i)' was fitted with type "nmatrix.3" but type "nmatrix.5" was supplied In addition: Warning message: In Z/rep(sqrt(norm2[-1L]), each = length(x)) : longer object length is not a multiple of shorter object length it falls over. I can't see the difference between the objects, summary() looks the same. Is somethi...
2004 Oct 20
2
Odd behaviour with scale()
...working, rather than it being a bug. Would anyone care to enlighten me? > Data1=data.frame(xx=1:10, yy=2.1:12) > Data1$xx=scale(Data1$xx) > > reg1=lm(yy~xx, data=Data1) > New=data.frame(xx=2:4) > b=predict(reg1, New, se.fit=T) Error: variable 'xx' was fitted with nmatrix.1 but numeric was supplied > > New=data.frame(xx=scale(2:4, center=5.5, scale=3.02)) > b=predict(reg1, New, se.fit=T) Error: variable 'xx' was fitted with nmatrix.1 but numeric was supplied > Bob -- Bob O'Hara Department of Mathematics and Statistics P.O. Box 68 (Gust...
2010 Dec 04
2
Problem storing lm() model in a list
...nd of the email. Here is an example of the error: > poly.fit <- polyModelSelection(x,y,10,F) > for (d in 1:4) { + lm.model <- poly.fit$models[[d]] + curve(predict(lm.model,data.frame(x)),add=T,lty=d+1) + } Error: variable 'poly(x, d, raw = T)' was fitted with type "nmatrix.1" but type "nmatrix.10" was supplied Does anyone have any ideas? Thanks, Harold ############################################################################ polyModelSelection <- function(x,y,maxd,add.dim=F) { dim.mult <- 0 if (add.dim) { dim.mult = 1...
2005 Jun 02
4
repeated vector in matrix
Hallo, I'll need a matrix with n rows of the an identical vector. > h [1] 3 3 3 3 2 2 2 The nmatrix should look like this: > x<-rbind(h,h,h) > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] h 3 3 3 3 2 2 2 h 3 3 3 3 2 2 2 h 3 3 3 3 2 2 2 but I need n rows which must be variable. Can anyone help me? thanks Andreas [[alternative...
2004 Jun 18
0
interpreter change from RW1.7 to RW1.8 reviewed at RW1.9
...ase forgive me just sending this report without offering any patches. You find my test code below, in case you like to have a look on it. I would appreciate your comments very much. Best regards Jens Oehlschl?gel # This example shows the slowdown (where as.ref and deref are defined as below) nmatrix <- 1000 nloop <- 100 m <- matrix(nrow=nmatrix, ncol=nmatrix) rm <- as.ref(m) # the following is by order of magnitudes (factor 20 to 80) slower # under R 1.8, R 1.9 (11.45 seconds) # compared to R 1.7, 1.6, 1.5 ( 0.12 seconds) system.time( for(i in 1:nloop) dere...
2008 Aug 13
3
issue building dataframes with matrices.
...match error. > df$out = df$x+df$y+df$yy + rnorm(3) > df x y yy out 1 1 1 1 3.066348 2 2 2 2 5.516017 3 3 3 3 11.073452 > glmout = glm(out~x+y+yy,data=df) > predict(glmout,newdata=data.frame(x=1:3,y=1:3,yy=1:3)) Error: variable 'yy' was fitted with type "nmatrix.1" but type "numeric" was supplied > > predict(glmout,newdata=data.frame(x=1:3,y=1:3,yy=matrix(1:3))) Error: variable 'yy' was fitted with type "nmatrix.1" but type "numeric" was supplied > predict(glmout,newdata=df[,-4]) 1 2...
2011 Apr 19
1
How to Extract Information from SIMEX Output
...")= int 1 .. .. ..- attr(*, "response")= int 1 .. .. ..- attr(*, ".Environment")=<environment: 0x0bd89124> .. .. ..- attr(*, "predvars")= language list(estimates, lambda, I(lambda^2)) .. .. ..- attr(*, "dataClasses")= Named chr [1:3] "nmatrix.2" "numeric" "numeric" .. .. .. ..- attr(*, "names")= chr [1:3] "estimates" "lambda" "I(lambda^2)" ..$ model :'data.frame': 5 obs. of 3 variables: .. ..$ estimates : num [1:5, 1:2] -13.27 -11.71 -10.47 -9.46 -8....
2011 Jun 03
0
How to reconcile Kalman filter result (by package dlm) with linear regression?
...[,2]        [,3]       [,4] [24,] -0.06046868 0.002829377 -0.01569903 0.03599957   I am pretty troubled by what I see here. So if anyone would offer me some condolence, as well as helpful advice, I am greatly grateful. Thanks a lot. Here are the code and the data.   Thanks a lot.   Wei   nTotal = nMatrix + 1 BuildMod <- function(x){  L1 = matrix(0,nFactor,nFactor)   L1[upper.tri(L1,T)] <- x[1:nMatrix]  return(dlm(   m0  = rep(0,nFactor),   C0  = diag(nFactor)*10,   FF  = matrix(1,1,nFactor),   GG  = diag(nFactor),   V   = tail(x,1)^2,   W   = crossprod(L1),   JFF = matrix(1:4,nr=1),   X   = X...
2003 Nov 11
0
Mismatches in predict(newdata)
...quot;)) && exists(".checkMFClasses", envir=NULL)) .checkMFClasses(cl, m) to be backwards compatible.) The exact nature of the `classes' is tricky because of inheritance. I have implemented logical, ordered, factor (not ordered), numeric (not matrix), nmatrix.n and other: nmatrix.n is a numeric matrix of n columns (as used by poly() and bs(), for example). Let me know if you see a need for other categories. Brian -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ Universit...
2006 Sep 01
1
difference between ns and bs in predict.glm
I am fittling a spline to a variable in a regression model, I am then using the predict.glm funtion to make some predictions. When I use bs to fit the spline I don't have any problems using the predict.glm function however when I use ns I get the following error: Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : variable lengths differ (found for
2009 Oct 07
0
error using predict() / "fRegression"-package
...regdata, use = "lm") > ar1.xpred.train.pred <- predict(ar1.xpred.fitted, regdata, se.fit = FALSE) > ar1.xpred.test.pred <- predict(ar1.xpred.fitted, regdata.test, se.fit = FALSE) Fehler: variable 'lag(ret1)' was fitted with type "numeric" but type "nmatrix.1" was supplied Zus?tzlich: Warnmeldung: 'newdata' had 23 rows but variable(s) found have 89 rows >
2017 Mar 30
0
get_all_vars() does not handle rhs matrices in formulae
...21.4 18.7 18.1 14.3 24.4 22.8 19.2 ... ## $ x : num 2.62 2.88 2.32 3.21 3.44 ... ## $ NA: num 110 110 93 110 175 105 245 62 95 123 ... This means attempts to use this data structure in predict() fail: str(predict(m2, get_all_vars(m2))) ## Error: variable 'x' was fitted with type "nmatrix.2" but type "numeric" was supplied The correct structure needs to resemble following in order for that to succeed: newdat <- data.frame(y = y) newdat$x <- x str(newdat) ## 'data.frame': 32 obs. of 2 variables: ## $ y: num 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8...
2009 Jul 20
3
Write in file matrices of sifferent size
Hi list, How to save a list content into a text file? Please consider example below, I have two numeric matrices that I bundle into a list & give each list element a name Example: > matrixA <- matrix(0,5,4) > matrixB <- matrix(1,7,13) > matrixList <- list(matrixA,matrixB) > names <- c("Matrix A","Matrix B") > names <-
2009 Jan 20
1
Creating a Sparse Matrix from a Sparse Vector
Hello, I am working with a sparse matrix that is approx. 13,900 by 14,100. My goal is to select a row out of the matrix and create a new matrix with that row repeated 13,900 times without having to do any looping. Example: Starting Matrix: exampleMatrix 3 x 4 sparse Matrix of class "dgCMatrix" [1,] 1 . . . [2,] . 1 . 0.5 [3,] . . 1 .. New Matrix:.. newExampleMatrix 3 x 4 sparse
2011 Apr 08
1
Variance of random effects: survreg()
I have the following questions about the variance of the random effects in the survreg() function in the survival package: 1) How can I extract the variance of the random effects after fitting a model? For example: set.seed(1007) x <- runif(100) m <- rnorm(10, mean = 1, sd =2) mu <- rep(m, rep(10,10)) test1 <- data.frame(Time = qsurvreg(x, mean = mu, scale= 0.5, distribution =
2013 Jan 29
3
how to suppress the intercept in an lm()-like formula method?
I'm trying to write a formula method for canonical correlation analysis, that could be called similarly to lm() for a multivariate response: cancor(cbind(y1,y2,y3) ~ x1+x2+x3+x4, data=, ...) or perhaps more naturally, cancor(cbind(y1,y2,y3) ~ cbind(x1,x2,x3,x4), data=, ...) I've adapted the code from lm() to my case, but in this situation, it doesn't make sense to include an