Displaying 20 results from an estimated 100 matches similar to: "Trying to use segmented in a function"
2011 Oct 18
1
cygwing warming when creating a package in windows
Dear All,
I am a beginner creating R packages. I followed the Leisch (2009) tutorial
and the document ?Writing R Extensions? to write an example.
I installed R 2.12.2 (I also tried R2.13.2), the last version of Rtools and
the recommended packages in a PC with Windows 7 Home Premium.
I can run R CMD INSTALL linmod in the command prompt and the R CMD check
linmod. The following outputs are
2010 Apr 19
2
nls minimum factor error
Hi,
I have a small dataset that I'm fitting a segmented regression using nls on.
I get a step below minimum factor error, which I presume is because residual
sum of square is still "not small enough" when steps in the parameter space
is already below specified/default value. However, when I look at the trace,
the convergence seems to have been reached. I initially thought I might
2010 Apr 19
3
nls for piecewise linear regression not converging to least square
Hi R experts,
I'm trying to use nls() for a piecewise linear regression with the first
slope constrained to 0. There are 10 data points and when it does converge
the second slope is almost always over estimated for some reason. I have
many sets of these 10-point datasets that I need to do. The following
segment of code is an example, and sorry for the overly precise numbers,
they are just
2013 Mar 12
1
Cook's distance
Dear useRs,
I have some trouble with the calculation of Cook's distance in R.
The formula for Cook's distance can be found for example here:
http://en.wikipedia.org/wiki/Cook%27s_distance
I tried to apply it in R:
> y <- (1:400)^2
> x <- 1:100
> lm(y~x) -> linmod # just for the sake of a simple example
>
2009 Oct 26
2
What is the most efficient practice to develop an R package?
I am reading Section 5 and 6 of
http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf
It seems that I have to do the following two steps in order to make an
R package. But when I am testing these package, these two steps will
run many times, which may take a lot of time. So when I still develop
the package, shall I always source('linmod.R') to test it. Once the
code in
2006 Jan 11
1
updating formula inside function
Dear R-Helpers
Given a function like
foo <- function(data,var1,var2,var3) {
f <- formula(paste(var1,'~',paste(var2,var3,sep='+'),sep=''))
linmod <- lm(f)
return(linmod)
}
By typing
foo(mydata,'a','b','c')
I get the result of the linear model a~b+c.
How can I rewrite the function so that the formula can be updated inside
the function,
2010 Apr 27
3
Problem calculating multiple regressions on a data frame.
Hi there,
I am stuck trying to solve what should be a fairly easy problem.
I have a data frame that essentially consists of (ID, time as seqMonth,
variable, value) and i want to find the regression coefficient of value vs
time for each combination of ID and Variable.
I have tried several approaches and none of them seems to work as i
expected.
For example, i have tried:
2018 Jan 20
1
Specification: Bi variate minimization problem
------------------- Version 2 of my problem improving the definition of what the optimal solution would be.
Dear all,
I'm working on the following problem:
Assume two datasets: Y, Y that represent the same physical quantity Q. Dataset X contains values of Q after an event A while dataset Y contains values of Q after an event B.
In R X, Y are vectors of the same length, containing
2017 May 31
2
stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
Le 31/05/2017 ? 17:30, Serguei Sokol a ?crit :
>
> More thorough reading revealed that I have overlooked this phrase in the
> line's doc: "left and right /thirds/ of the data" (emphasis is mine).
Oops. I have read the first ref returned by google and it happened to be
tibco's doc, not the R's one. The layout is very similar hence my mistake.
The latter does not
2010 Jun 18
1
How to calculate the robust standard error of the dependent variable
Hi, folks
linmod=y~x+z
summary(linmod)
The summary of linmod shows the standard error of the coefficients. How can
we get the sd of y and the robust standard errors in R?
Thanks!
[[alternative HTML version deleted]]
2009 May 13
1
Block factor as random or fixed effect?
People
I apologise for asking a general stats question, but I'm at a bit of a
loss as to what to do following some hostile referees' comments. If I
have a fully randomised blocked design, with only three blocks, should
I treat block as a random or fixed effect? I have read comments about
not treating block as a random effect if the number of blocks is less
than 6 or 7: is this
2007 Oct 13
2
How to identify the two largest peaks in a trimodal distribution
Hello all
I'm trying to do a simulation that involves identifying the minimum
point between two peaks of a (usually) bimodal distribution. I can do
this easily if there are only two peaks:
CnBdens<-density(Ys/Xs) #probability density function for ratio of Ys
to Xs
for(p in 1:512) ifelse(CnBdens$y[p]>CnBdens$y[p-1],peak1<-p,break)
#identifies first peak in probability
2010 Jun 21
2
How to predict the mean and variance of the dependent variable after regression
Hi, folks,
As seen in the following codes:
x1=rlnorm(10)
x2=rlnorm(10,mean=2)
y=rlnorm(10,mean=10)### Fake dataset
linmod=lm(log(y)~log(x1)+log(x2))
After the regression, I would like to know the mean of y. Since log(y) is
normal and y is lognormal, I need to know the mean and variance of log(y)
first. I tried mean (y) and mean(linmod), but either one is what I want.
Any tips?
Thanks in
2008 Mar 14
1
Comparing switchpoints from segmented
Hello everyone
Not strictly an R question but close... hopefully someone will be able
to help. I wish to compare the switchpoints in two switchpoint
regressions. The switchpoints were estimated using the segmented
library running in R, and I have standard errors for the estimates. I
initially thought I could just bootstrap confidence intervals for the
difference between the switchpoints,
2009 Sep 14
3
Eliminate cases in a subset of a dataframe
Hi folks,
I created a subset of a dataframe (i.e., selected only men):
subdata <- subset(data,data$gender==1)
After a residual diagnostic of a regression analysis, I detected three
outliers:
linmod <- lm(y ~ x, data=subdata)
plot(linmod)
Say, the cases 11,22, and 33 were outliers.
Here comes the problem: When I want to exclude these three cases in a
further regression analysis,
- for
2012 May 29
2
setting parameters equal in lm
Forgive me if this is a trivial question, but I couldn't find it an answer
in former forums. I'm trying to reproduce some SAS results where they set
two parameters equal. For example:
y = b1X1 + b2X2 + b1X3
Notice that the variables X1 and X3 both have the same slope and the
intercept has been removed. How do I get an estimate of this regression
model? I know how to remove the intercept
2008 Mar 10
3
Weighting data when running regressions
Dear R-Help,
I'm new to R and struggling with weighting data when I run regression. I've
tried to use search to solve my problem but haven't found anything helpful
so far.
I (successfully) import data from SPSS (15) and try to run a linear
regression on a subset of my data file where WEIGHT is the name of my
weighting variable (numeric), e.g.:
library(foreign)
2004 Mar 17
1
ANCOVA when you don't know factor levels
Hello people
I am doing some thinking about how to analyse data on dimorphic animals
- where different individuals of the same species have rather different
morphology. An example of this is that some male beetles have large
horns and small wings, and rely on beating the other guys up to get
access to mates, whereas others have smaller horns and larger wings,
and rely on mobility to
2003 Dec 02
1
changing axis font size in a pairs plot?
Hello
Can anyone let me know how I might change the size of the numbers on the
axes in a pairs plot? The normal cex.axis call doesn't do anything,
cex.labels only seems to change the font size in the diagonal labels. Using
R 1.8.0 on a Mac with OS X.3.
Thanks
Rob Knell
2005 Jan 10
1
Partial wireframe plots
Dear R-helpers
Can anyone direct me to a method for plotting what you might call a
partial wireframe plot? I have two explanatory variables in a dataset
which give me a significant interaction term when I fit a model. The
two variables are correlated with each other to a moderate degree, and
if I plot the predicted values from the model as a surface in a 3D
wireframe plot there are some