search for: yvar

Displaying 20 results from an estimated 64 matches for "yvar".

Did you mean: var
2004 Oct 11
2
question on function argument
dear all, i've looked at the r-intro (chapter 10, writing your own functions) and searched the r-help archives but am still stuck at the following. i have a simple function, something like: myhist<-function(yvar) { y<-subset(myframe,yvar>1 & yvar<=150000,select=yvar) attach(y) hist(yvar) } calling it as follows: myhist(x1) gives the following error: Error in attach(y) : attempt to set an attribute on NULL what am i doing wrong here? thanks in advance, edwin
2005 Jul 05
1
by (tapply) and for loop differences
I am getting a difference in results when running some analysis using by and tapply compare to using a for loop. I've tried searching the web but had no luck with the keywords I used. I've attached a simple example below to illustrates my problem. I get a difference in the mean of yvar, diff and the p-value using tapply & by compared to a for loop. I cannot see what I am doing wrong. Can anyone help? > # Simulate some data - I'll do 2 simulations... > > xvar = rnorm(40, 20, 5) > yvar = rnorm(40, 22, 2) > num = factor(rep(1:2, each=20)) > sdat = data.fr...
2007 Jun 14
4
question about formula for lm
Dear all; Is there any way to make this to work?: .x<-rnorm(50,10,3) .y<-.x+rnorm(50,0,1) X<-data.frame(.x,.y) colnames(X)<-c("Xvar","Yvar") Ytext<-"Yvar" lm(Ytext~Xvar,data=X) # doesn't run lm(Yvar~Xvar,data=X) # does run The main idea is to use Ytext as input in a function, so you just type "Yvar" and the model should fit.... Also, I need to avoid the expression X$Yvar~X$Xvar Thanks for any idea...
2012 Aug 11
1
using eval to handle column names in function calling scatterplot graph function
...blems with a function I'm trying to create to: 1. subset a data.frame based on function arguments (colname & parmname) 2. rename the PARMVALUE column in the data.frame based on function argument (xvar) 3. generate charts plotvar <- function(parentdf,colname, parmname,xvar,yvar ){ subdf <- parentdf[substr(colname,1,nchar(parmname)) == parmname,] names(subdf) <- sub('PARMVALUE',xvar, names(subdf)) xvarcol <- paste("subdf","$",xvar,sep="") yvarcol <- paste("subdf","$",yvar,sep="&q...
2007 Nov 15
1
Writing a helper function that takes in the dataframe and variable names and then does a subset and plot
...lwd=2,col.line='red', ...) }, xlab = xylabels[1], ylab= xylabels[2]) } plotwithfits(Latency ~ Stimulus.number | Subject.ID,eye_subsetted_data) # Works However, I can't get it working if I try the same for a subset and plot: explorebysubject <- function(xvar,yvar,data,condition=TRUE,xlim=c(-Inf,Inf),ylim=c(-Inf,Inf)) { temp_subset <- subset(data, subset=condition&xvar>xlim[1]&xvar<xlim[2]&yvar>ylim[1]&yvar<ylim[2], select=c(Group,Subject.ID,xvar,yvar)...
2009 Apr 21
6
Sampling in R
[This email is either empty or too large to be displayed at this time]
2011 Feb 25
1
speed up process
...t might also look too complex for what it is intended to do, but my colleagues who are also supposed to use it don't know much about R. So I wrote it so that they don't have to modify the critical parts to run the script for their needs. #column indexes for function ind.xvar <- 2 seq.yvar <- 3:4 #position vector for legend(), stupid positioning but it doesn't matter here mypos <- c("topleft", "topright","bottomleft") #run the function for columns 3&4 as y (seq.yvar) with column 2 as x (ind.xvar) for all 3 datasets (mydata_list) par(mfrow...
2011 Apr 01
3
programming: telling a function where to look for the entered variables
...on for different dataframes and variables. My problem is that I'm not quite sure how to tell my function in which dataframe the entered variables are located. Here's some reproducible data and the function: # create reproducible data set.seed(124) xvar <- sample(0:3, 1000, replace = T) yvar <- sample(0:1, 1000, replace=T) zvar <- rnorm(100) lvar <- sample(0:1, 1000, replace=T) Fulldf <- as.data.frame(cbind(xvar,yvar,zvar,lvar)) Fulldf$xvar <- factor(xvar, labels=c("blue","green","red","yellow")) Fulldf$yvar <- factor(yvar, labe...
2011 Apr 18
1
covariance matrix: a erro and simple mixed model question, but id not know answer sorry
...nowledge. #example data set set.seed (134) lm=c(1:4) block = c(rep(lm,6)) gen <- c(rep(1, 4), rep(2, 4), rep(3, 4), rep(4, 4),rep(5, 4),rep(6, 4)) X1 = c( rnorm (4, 10, 4), rnorm (4, 12, 6), rnorm (4, 10, 7),rnorm (4, 5, 2), rnorm (4, 8, 4), rnorm (4,7, 2)) X2 = X1 + rnorm(length(X1), 0,3) yvar <- c(X1, X2) X <- c(rep( 1, length(X1)), rep( 2, length(X2))) # dummy x variable dataf <- data.frame(as.factor(block), as.factor(gen), as.factor(X), yvar ) My objective to estimate variance-covariance between two variables X1 and X2. Means that I need to fit something like unstructure...
2008 Nov 15
1
Lattice: groups and no groups with panel.superpose
...t, but I can't find an example for what I want to do... with the following example data (from another post): years<-2000:2006 weeks<-1:20 yr<-rep(years,rep(length(weeks)*6,length(years))) wk<-rep(weeks,rep(6,length(weeks))) temp<-rep(4:9,length(years)*length(weeks)) yvar<-round(rnorm(length(years)*length(weeks)*6,mean=30,sd=4),0) xvar<-(rnorm(length(years)*length(weeks)*6)+5)/10 df<-data.frame(year=yr,week=wk,temp=temp, yvar=yvar, xvar=xvar) I get the regression lines per group for each panel using: xyplot(yvar~year|week,data=df,layout =...
2010 Aug 09
1
Different colour in each bar in lattice package
...426, 0.724387494422558, 0.666908727580774, 0.66291862672965), trat = structure(c(5L, 1L, 3L, 2L, 4L, 5L, 1L, 3L, 2L, 4L, 1L, 5L, 2L, 3L, 4L, 5L, 1L, 2L, 4L, 3L, 5L, 1L, 2L, 3L, 4L), .Label = c("O", "P", "Pl", "T", "TN"), class = "factor"), Yvar = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L), .Label = c("0BG", "0BP", "0T", "1A", "1D"), class = "factor")), .Names = c("Medias", "ICI", "ICS&qu...
2013 Sep 26
1
Less than equal to symbol in ggplot2 legend text
...(data[,covariate]>cutpoint,1,0) Grp1 <- "\u2264 1.5" Grp2 <- ">1.5" Extra.column=factor(Extra.column,levels=c(0,1),labels=c(Grp1,Grp2)) data2=cbind.data.frame(data,Extra.column) df <- ddply(data2, .(Time,Extra.column), summarize, N = length(Yvar), meanYvar=mean(Yvar), seYvar=sd(Yvar)/sqrt(length(Yvar))) df = df[df$N>=10,] PLot=ggplot(df, aes(x=AVST, y=meanYvar, shape=Extra.column)) + scale_y_continuous(name="Mean Yvar ± SE" )+ scale_x_continuous(name="Time (year)")+ theme(axis.text.x = element_text(size=16,c...
2011 Feb 28
0
Fwd: Re: speed up process
...;- mydata1[!(mydata1$species %in% c("thgel","alsen")),] mydata3<- mydata1[!(mydata1$species %in% c("thgel","alsen","poabe")),] mydata_list<- list(mydata1=mydata1, mydata2=mydata2, mydata3=mydata3) library(WRS) foo_reg<- function(dat, xvar, yvar, mycol, pos, name.dat){ tsts<- tstsreg(dat[[xvar]], dat[[yvar]]) tsts_inter<- signif(tsts$coef[1], digits=3) tsts_slope<- signif(tsts$coef[2], digits=3) abline(tsts$coef, lty=1, col=mycol) legend(x=pos, legend=c(paste("TSTS ",name.dat,": Y=",tsts_inter,"...
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
Dear All Sorry for this simple question, I could not solve it by spending days. My data looks like this: # data set.seed(1234) clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100 level for this factor var; yvar <- rnorm(40, 10,6); var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2); var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15, 8) # just example df <- data.frame(clvar, yvar, var1, var2, var3, var4, var5) # manual splitting df1 <- subset(df, clvar == 1) df2...
2011 Apr 15
1
no solution yet, please help: extract p-value from mixed model in kinship package
...*******************************x and y variables ********************* > set.seed(3456) > > dat <- sample(c(-1,0,1), 10000, replace = TRUE) > > snpmat<- data.frame(matrix(dat, ncol = 100)) > > names(snpmat) <- c(paste ("VR",1:100, sep='' )) > > yvar <- rnorm(100, 30, 5) > covtrait <- rnorm(100, 10, 5) > > mydata <- data.frame(id, yvar, covtrait, snpmat) > #******************************mixed model in lmekin ******************************************* > > fmod <- lmekin(yvar ~ mydata[,3] , data= mydata, random =...
2019 May 25
3
Increasing number of observations worsen the regression model
I have the following code: ``` rm(list=ls()) N = 30000 xvar <- runif(N, -10, 10) e <- rnorm(N, mean=0, sd=1) yvar <- 1 + 2*xvar + e plot(xvar,yvar) lmMod <- lm(yvar~xvar) print(summary(lmMod)) domain <- seq(min(xvar), max(xvar))??? # define a vector of x values to feed into model lines(domain, predict(lmMod, newdata = data.frame(xvar=domain)))??? # add regression line, using `predict` to generate y-...
2011 Aug 30
1
R crash
...ke R crash by running dev.off(). Is there anything else than sessionInfo()? Thank you for your help, Ivan -------- script --------- library(R.utils) library(RSvgDevice) library(doBy) primate_med <- loadObject("primate_med.Rbin") select <- primate_med #data object to use seq.yvar <- c(5,12,8,9) ind.xvar <- 4 filename <- paste("regression", names(datobj)[ind.xvar], paste(names(datobj)[seq.yvar],collapse="_"), paste(selvarstr,collapse="_"), sep="_") filename <- gsub(".median", "", filename) sele...
2011 Oct 12
2
Nonlinear regression aborting due to error
Colleagues, I am fitting an Emax model using nls. The code is: START <- list(EMAX=INITEMAX, EFFECT=INITEFFECT, C50=INITC50) CONTROL <- list(maxiter=1000, warnOnly=T) #FORMULA <- as.formula(YVAR ~ EMAX - EFFECT * XVAR^GAMMA / (XVAR^GAMMA + C50^GAMMA)) ## alternate version of formula FORMULA <- as.formula(YVAR ~ EMAX - EFFECT / (1 + (C50/XVAR)^GAMMA)) FIT <- nls(FORMULA, start=START, control=CONTROL, trace=T) If GAMMA equals 10-80, nls converges successfully and the fit tracks...
2012 Sep 20
1
Gummy Variable : Doubt
...er cases (H1: equal mesor, H2.x: equal amplitude and acrophase, H3: equal rhythmic components). I suppose I have to use dummy variables, but I don’t know how to do it.   I could access something similar in a solution manual of  a Weisberg book (1985), chapter 6, problem 9, as follows: m1 <- lm(Yvar~ Xvar + Fvar + Fvar:Xvar, na.action=na.omit, weights=theWeights)  # this is model 1 the most general m2 <- lm(Yvar~ Xvar + Fvar            , na.action=na.omit, weights=theWeights)  # this is model 2 parallel m3 <- lm(Yvar~ Xvar + Fvar:Xvar       , na.action=na.omit, weights=theWeights)  # t...
2005 Dec 26
4
lme X lmer results
Hi, this is not a new doubt, but is a doubt that I cant find a good response. Look this output: > m.lme <- lme(Yvar~Xvar,random=~1|Plot1/Plot2/Plot3) > anova(m.lme) numDF denDF F-value p-value (Intercept) 1 860 210.2457 <.0001 Xvar 1 2 1.2352 0.3821 > summary(m.lme) Linear mixed-effects model fit by REML Data: NULL AIC BIC logLik 5416.59 5445.256 -27...