search for: dfxy

Displaying 6 results from an estimated 6 matches for "dfxy".

Did you mean: dfx
2012 Apr 24
1
Use of optim to fit two curves at the same time ?
...wo functions. Is it possible to fit two functions (like those two for example) at the same time using optim ... or another function in R ? Thanks Arnaud ###################################################################### ## function 1 x1 <- 1:100 y1 <- 5.468 * x + 3 # + rnorm(100,0, 10) dfxy <- cbind(x1,y1) # Objective function optfunc <- function(x, dfxy){ a <- x[1] b <- x[2] xtest <- dfxy[,1] yobs <- dfxy[,2] ysim <- a*xtest + b sum((ysim - yobs)^2) } out<- optim(par=c(0.2,5), fn=function(x){optfunc(x, dfxy)}, method = "Nelder-Mead", he...
2010 Dec 27
3
Drop column from a data frame
...n of a data frame. The code below attempts to drop a numeric column (which does not work but gives no error or warning) and a factor column (which does not work but gives an error). I would appreciate someone telling me why my code does not work, and suggesting code that will work. Thanks, John rm(dfxyz,dfxz,dfxy) # create the data frame. dfxyz <- data.frame(x=1:10,y=11:20,z=factor(c(rep(0,5),rep(1,5)))) dfxyz names(dfxyz) # try to drop y column # does not work, does not produce error message dfxz <- dfxyz[,-(dfxyz$y)] dfxz # try to drop z column # does not work, produces error message:...
2011 Jan 06
4
Different LLRs on multinomial logit models in R and SPSS
...;c"=sample(1:2, 143, repl=T) ) library(nnet) mod1 <- multinom(y ~ ., data=df, trace=F) deviance(mod1) # 199.0659 mod0 <- update(mod1, . ~ 1, trace=FALSE) deviance(mod0) # 204.2904 Output data and syntax for SPSS: df2 <- df df2[, 1] <- as.numeric(df[, 1]) write.csv(df2, file="dfxy.csv", row.names=F, na="") syntaxfile <- "dfxy.sps" cat('GET DATA /TYPE=TXT /FILE=\'', getwd(), '/dfxy.csv\' /DELCASE=LINE /DELIMITERS="," /QUALIFIER=\'"\' /ARRANGEMENT=DELIMITED /FIRSTCASE=2 /IMPORTCASE=ALL /VA...
2008 Apr 01
1
superimpose histogram on biplot
...als(mat, nf=9) scatter(nipmat) In the plot generated by the above "scatter" command, there is a histogram in the upper left corner. I want to know how to superimpose that histogram on a similar plot, such as the following: groups = as.factor(c(rep(1,2), rep(2,4), rep(3,4))) s.arrow(dfxy=nipmat$co[,1:2]*8, sub="Day 10", possub="bottomleft", csub=3) s.class(dfxy=nipmat$li[,1:2], fac=groups, cellipse=2, axesell=F, cstar=0 , col=c(2:3), add.plot=T) I can create the histogram using: plot(nipmat$eig/sum(nipmat$eig), type='h') but I don't know how t...
2005 Sep 21
3
Sort a data frame with respect to more than one variable
Dear All, How can I sort a data frame with respect to more than one variable? I know that for one variable X one may use: df[order(df$X), ] where df is the data frame containing X. Many thanks, Bernard --------------------------------- [[alternative HTML version deleted]]
2008 Oct 15
0
R-help Digest, Vol 67, Issue 31
...lot generated by the above "scatter" command, there is a >> histogram in the upper left corner. I want to know how to >> superimpose that histogram on a similar plot, such as the following: >> >> groups = as.factor(c(rep(1,2), rep(2,4), rep(3,4))) >> s.arrow(dfxy=nipmat$co[,1:2]*8, sub="Day 10", possub="bottomleft", >> csub=3) >> s.class(dfxy=nipmat$li[,1:2], fac=groups, cellipse=2, axesell=F, >> cstar=0 , col=c(2:3), add.plot=T) >> >> I can create the histogram using: >> >> plot(nipmat$eig/sum(n...