Re: [R] GLM: What is a good way for dealing with new factor levels in the test set?

2015-04-29 Thread Jim Lemon
Hi thuksu, Would defining the factor in your training set with all the levels that occur in the test set solve the problem? That is, there would be at least one factor level in the training set even though there were no instances of that factor. Jim On Thu, Apr 30, 2015 at 8:05 AM, thuksu wrote

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Jim Lemon
Hi Olufemi, I sounds like you have a data frame (let's call it "mydata") with at least three elements (columns). You may be trying to use c() in this way: y1to3<-c(y1,y2,y3) in which case it won't work. However: y1to3<-c(mydata$y1,mydata$y2,mydata$y3) might do what you want, substituting whatev

[R] help - hoslem.test

2015-04-29 Thread Luciane Maria Pilotto
Hello, I'm working with ordinal logistic regression model (polr) and would like to test the proportional odds assumption. For this, I ran the binary logistic regressions with varying cutpoints on the dependent variable, as described in the following commands. When running the test of Hosmer and

[R] GLM: What is a good way for dealing with new factor levels in the test set?

2015-04-29 Thread thuksu
My training set and my test set have some factor levels that are different It's rare, but it occurs. What is a good way for dealing with this? I don't want to throw away the entire row from the data frame, because there is some valuable information in there. Is there some way to say somethi

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Jeff Newmiller
I am sure you can use c() because columns may be vectors even though vectors are not columns, but you really need to follow the posting guide and provide a reproducible example for us to show you how. You might find [1] helpful, in particular as it describes the use of the dput function to give

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Olufemi Bolarinwa
Thank you Jeff for your response. My y1, y2, y3 are actually 3 columns in the data so I cannot use the c() function to concatenate them. I am confusing the "columns" with vectors. I actually meant columns. Any help will be much appreciated Olufemi  On Wednesday, 29 April 2015, 22:31, Jef

Re: [R] Stacking of vectors to form a column vector

2015-04-29 Thread Jeff Newmiller
Vectors are not "columns" or "rows". Use the c() function to concatenate vectors. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

[R] Stacking of vectors to form a column vector

2015-04-29 Thread Olufemi Bolarinwa
Hello,I am estimating a system of nonlinear equation where I need to stack my vector of y. I have data of about 6000units. I tried using the rbind but instead of having a vector of 1 by 18000, it is giving me a 3 by 6000 so that my matrix multiplication is non-conformable. The stack command requ

Re: [R] LM() and time in R

2015-04-29 Thread Jim Lemon
Hi Livia, >From your description, it sounds like the "time" variable is actually a vector of date strings like "30/04/2015". These will usually be input as "factors" in R, meaning that you probably had a very large number of categorical values instead of numeric. To find out, do this: is.factor(ti

Re: [R] DeSolver giving "NA" as output, but running fully.

2015-04-29 Thread walke554
All of the data you need to run the ODE integrator is there. all the parameters and starting populations and values are given under the: "#giving the parameters" section of the code. -- View this message in context: http://r.789695.n4.nabble.com/DeSolver-giving-NA-as-output-but-running-fully

Re: [R] Need Help!

2015-04-29 Thread Boris Steipe
A: Look at the function seq() e.g. seq(0.01, 1, by=0.005) B: Don't post in HTML. Seriously. Do not. C: You need to invest more time getting the basics down. Google for R introduction. D: Ow. pi is a predefined constant. Your re-defintion loses accuracy. (See C:) Please see here for some hints

Re: [R] How to solve: error in file(file, "rt") : invalid 'description' argument

2015-04-29 Thread Boris Steipe
If you google for "invalid 'description' argument" it should be pretty clear what's going on - most likely your DirPath_Matrix is not a single item. B. On Apr 28, 2015, at 7:02 PM, catherine peters wrote: > Hi thank you in advance for your assistance. > > I am using the following section o

[R] Cross-Validate a Multivariate Polynomial Regression with K-folds

2015-04-29 Thread Nicolae Doban
Hi, could you tell me please which is the fastest and most accurate way/algorithm/code of cross-validating a Multivariate Polynomial Regression with K-folds? I have a dataframe of 5 input variables and I want to predict one output variable. Every variable features a different power for which the e

Re: [R] LM() and time in R

2015-04-29 Thread Boris Steipe
Have a look at the help page for the function ts() (type ?ts at the R prompt). Other than that, you haven't provided nearly enough information for us to diagnose your issue. Please see here for some hints on how to ask questions productively: http://adv-r.had.co.nz/Reproducibility.html http://

Re: [R] Forecasting prices

2015-04-29 Thread ce
Prof. Hydman's book is a good place to start : https://www.otexts.org/fpp -Original Message- From: "randomness" [m.kof...@aew.eu] Date: 04/28/2015 01:52 PM To: r-help@r-project.org Subject: [R] Forecasting prices Hi, apologies in advance for the generic question but I would highly appre

Re: [R] Problem with predict.lm()

2015-04-29 Thread ARNAB KR MAITY via R-help
Hi, It seems to be working in my R. Although it is throwing the warning message Warning message:'newdata' had 200 rows but variables found have 100 rows   y  [1] -1.071307580  0.102414204 -0.965046207  1.386057875  0.726835339  [6] -0.186549950 -0.777144258  1.137210314 -1.069446945 -0.696084338 [

[R] Need Help!

2015-04-29 Thread dawood ahmad
Dear Sir/Madam, I hope you will be fine. Recently, I have started to use R language. I am new in programming. I have to fit my data with mathematical equation which I am pasting below. The problem is that one of the parameter named "ep" which is x-axis required a loop so that I could a range o

[R] LM() and time in R

2015-04-29 Thread Livia Maria Vestergaard
Hello, I need some help with a project that I’m working one. Im trying to make a l regression model (lm) in r with time as independant variable and gas prices as the depended. But It seems like everything im trying to run it, R freeze, I think that I need to tell R somehow that my time is time

[R] How to solve: error in file(file, "rt") : invalid 'description' argument

2015-04-29 Thread catherine peters
Hi thank you in advance for your assistance.  I am using the following section of script:  DirPath_folder  <-Sys.glob(file.path("/Users/catpeters/Documents/R_working_directory/1_Data_MC_Sorted"))   for (folder in 1: length(DirPath_folder)) {  # ## EVERY Control and Impact #  DirPath_Matrix <-Sy

Re: [R] Problem with predict.lm()

2015-04-29 Thread Martin Spindler
Thank you! I think I now understand where the problem was. Best, Martin     Gesendet: Mittwoch, 29. April 2015 um 16:50 Uhr Von: "David L Carlson" An: "Martin Spindler" , "r-help@r-project.org" Betreff: RE: [R] Problem with predict.lm() Since you passed a matrix to lm() and then a data.frame

Re: [R] Problem with predict.lm()

2015-04-29 Thread Martin Spindler
Dear Arnab,   Thank you very much for your reply. It does not give an error message. The problem is that predict does "work and predict" on the old data and does not make the predictions with the provided new data.   Best,   Martin     Gesendet: Mittwoch, 29. April 2015 um 16:51 Uhr Von: "ARNAB K

Re: [R] Problem with predict.lm()

2015-04-29 Thread David Winsemius
On Apr 29, 2015, at 7:21 AM, Martin Spindler wrote: > Dear all, > > the following example somehow uses the "old data" (X) to make the > predictions, but not the new data Xnew as intended. > > y <- rnorm(100) > X <- matrix(rnorm(100*10), ncol=10) > lm <- lm(y~X) > Xnew <- matrix(rnorm(100*20)

Re: [R] Problem with predict.lm()

2015-04-29 Thread David L Carlson
Since you passed a matrix to lm() and then a data.frame to predict(), predict can't match up what variables to use for the prediction so it falls back on the original data. This seems to work: > set.seed(42) > y <- rnorm(100) > X <- matrix(rnorm(100*10), ncol=10) > Xd <- data.frame(X) > lm <- lm

[R] Problem with predict.lm()

2015-04-29 Thread Martin Spindler
Dear all,   the following example somehow uses the "old data" (X) to make the predictions, but not the new data Xnew as intended.   y <- rnorm(100) X <- matrix(rnorm(100*10), ncol=10) lm <- lm(y~X) Xnew <- matrix(rnorm(100*20), ncol=10) ynew <- predict(lm, newdata=as.data.frame(Xnew)) #prediction

Re: [R] Help with lattice panel function

2015-04-29 Thread Duncan Mackay
Did you want both "groups" to have loess? xyplot(x + max.x ~ date, data = my.newdf, ylab = "x", panel = function(x, y, x2, ...){ panel.xyplot(x, y, type = "l") panel.loess(as.numeric(my.newdf$date), my.newdf$max.x, lty = 2) #panel.xyplot(x, y2, type = "l")

Re: [R] invalid function value in 'nlm' optimizer

2015-04-29 Thread Duncan Murdoch
On 29/04/2015 9:49 AM, Hanze Zhang wrote: How should I do? The issue happened on log likelihood function? I imagine it's the log(x[delta==1]) term that is turning the result into a vector. Duncan Murdoch On Tue, Apr 28, 2015 at 11:06 PM, William Dunlap > wrote:

Re: [R] invalid function value in 'nlm' optimizer

2015-04-29 Thread Hanze Zhang
How should I do? The issue happened on log likelihood function? On Tue, Apr 28, 2015 at 11:06 PM, William Dunlap wrote: > Your function ln() does not return a scalar. >> ln(theta=c(1,2)) >[1] 48.5342640972 48.5342640972 48.5342640972 48.5342640972 48. > 5342640972 > > > Bill Dunlap > TIB

Re: [R] Help with lattice panel function

2015-04-29 Thread Naresh Gurbuxani
Thanks for your lightening fast response. This solution works. Sent from my iPhone > On Apr 29, 2015, at 7:27 AM, Brandstätter Christian > wrote: > > This worked for me. It is btw. quite confusing to name your y-variable x. > I think part of the problem arised from the date format. > > xyp

Re: [R] package.skeleton warning

2015-04-29 Thread Duncan Murdoch
On 29/04/2015 3:49 AM, carol white wrote: > So I finally used > filenames <- list.files("~/Desktop/myPkg/R/", full.names = TRUE) > package.skeleton(name = "myPackage", code_files = filenames) > > and still despite the warnings mentioned before, the man and R folders > seem to have been created cor

Re: [R] Help with lattice panel function

2015-04-29 Thread Brandstätter Christian
This worked for me. It is btw. quite confusing to name your y-variable x. I think part of the problem arised from the date format. xyplot(x + max.x ~ date, data = my.newdf, ylab = "x", panel = function(x, y, x2, ...){ panel.xyplot(x, y, type = "l") panel.loess(as.numeric(m

[R] Help with lattice panel function

2015-04-29 Thread Naresh Gurbuxani
I want to plot multiple variables in xyplot, but plot loess trend for only one of these variables. My problem is that the last command below does not give the desired result. Any help will be gratefully received. Thanks,Naresh my.df <- data.frame(date = as.numeric(as.Date("2015-01-01")) + 0:49,

Re: [R] package.skeleton warning

2015-04-29 Thread carol white via R-help
So I finally used filenames <- list.files("~/Desktop/myPkg/R/", full.names = TRUE) package.skeleton(name = "myPackage", code_files = filenames) and still despite the warnings mentioned before, the man and R folders seem to have been created correctly. I had put the vignettes folder and inst in t