Displaying 20 results from an estimated 23 matches for "ynew".
Did you mean:
new
2010 Oct 29
1
Simulating data, loop
...t a maximum of 20 values has
been removed from variable Y.
How can I tell R to put some removed values back in the data set, or to
remove more values until a maximum number of removed values has been
reached?
y <- rnorm(40,1,3)
x <- 1+2*y1+ rnorm(40,0,5)
#Remove values in Y dependent on X:
ynew <- rep(NA,40)
for (j in 1:40)
{
if (x[j] < 0){ynew[j] <- rbinom(1,1,0.50)}
if (x[j] > 0){ynew[j] <- rbinom(1,1,0.10)}
}
--
View this message in context: http://r.789695.n4.nabble.com/Simulating-data-loop-tp3019044p3019044.html
Sent from the R help mailing list archive at Nabble.com.
2012 Jul 02
0
Fit circle with R
...Mz = Mxx + Myy;
Cov_xy = Mxx*Myy - Mxy*Mxy;
Mxz2 = Mxz*Mxz;
Myz2 = Myz*Myz;
A2 = 4*Cov_xy - 3*Mz*Mz - Mzz;
A1 = Mzz*Mz + 4*Cov_xy*Mz - Mxz2 - Myz2 - Mz*Mz*Mz;
A0 = Mxz2*Myy + Myz2*Mxx - Mzz*Cov_xy - 2*Mxz*Myz*Mxy + Mz*Mz*Cov_xy;
A22 = A2 + A2;
epsilon=1e-12;
ynew=1e+20;
IterMax=20;
xnew = 0;
# Newton's method starting at x=0
epsilon=1e-12;
ynew=1e+20;
IterMax=20;
xnew = 0;
iter=1:IterMax
for (i in 1:IterMax){
yold = ynew;
ynew = A0 + xnew*(A1 + xnew*(A2 + 4.*xnew*xnew));
if (abs(ynew) > ab...
2008 Apr 10
6
two graphs in one figure?
...it just doesnt look as if they match in their scale
(the barplot is much wider than the "plot"....even though I tried to put
limits on the x-axis).
Here is an example of what I did:
barplot(y, xaxt="n",yaxt="n",ylim=c(-1,45), xlim=c(1,55))
...
par(new=TRUE)
plot(x, ynew, lty=2, type="l", ylim=c(0,15), xlim=c(1,55))
Another question: how can I make sure that the "0"-values from the barchart
are displayed as well?
Thank you so much!
Anne-Katrin
--
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games!
http://games.ent...
2010 Oct 03
2
How to programme R to randomly replace some X values with Outliers
Dear experts,
I am a beginner of R.
I'm looking for experts to guide me how to do programming in R in order to
randomly replace 5 observations in X explanatory variable with outliers drawn
from U(15,20) in sample size n=100. The replacement subject to y < 15.
The ultimate goal of my study is to compare the std of y with and without the
presence of outliers based on average of 1000
2010 Oct 06
2
A problem --thank you
dear:teacher
i have a problem which about the polr()(package "MASS"), if the response must have 3 or more levels?
and how to fit the polr() to 2 levels?
thank you.
turly yours
[[alternative HTML version deleted]]
2007 Aug 19
1
Creating a data set within a function
...data series and order represents the level of the process. In other words if order=2 then we have an AR (2) process. Now it is easy to to create the y vector within the function, but I'm not clear on how to create the design matrix.
For instance if order=2 then
y <- as.matrix(rnorm(100))
ynew <- as.matrix(y[3:nrow(y),1])
x <- as.matrix(cbind(rep(1, nrow(y)-2), y[2:(nrow(y)-1),1], y[1:(nrow(y)-2),1]))
ynew and x gives me the response vector and design matrix respectively. however, I'm trying to write a general function which will accomodate any order. Hence given the user inpu...
2006 Mar 16
1
lme4/Matrix: Call to .Call("mer_update_y"...) and LMEoptimize gives unexpected side effect...
...on sampled data sets. To speed up calculations, I've tried to use internal functions from the Matrix package (as suggested ealier on the list by Doug Bates).
So I did:
fm2 <- lmer(resistance ~ ET + position + (1|Grp), Semiconductor,method='ML')
simdata<-simulate(fm2,nsim=1)
ynew <- simdata[,1]
mer <- fm2
.Call("mer_update_y", mer, ynew, PACKAGE = "Matrix")
mer1u <- LMEoptimize(mer, lmerControl(mer))
What puzzles me is that this call alters my original model fm2 as some kind of side effect. In fact, after the call fm2 is the same as mer1u....
2005 Dec 29
2
How to fit all points into plot?
Hi,
I have a problem when I want to add new points (or a
new line) to the graph. Some points (or parts of the
line) are not shown on the graph because they lie
beyond the scale of the axis. Is there a way to
overcome this so all points (or the entire line) are
shown on the graph? Here's an example of my problem:
colors = c("red", "blue")
plot(x=rnorm(100,0,1),
2005 Feb 13
2
row equality.
I think that this is an easy one...
I have a matrix where each row is an (x,y,z) triplet. Given a potential
(xnew,ynew,znew) triplet I want to know if the matrix already contains a
row with the new values (the space already has that point). I can do it
using a for loop, but I would like to know if there is anyway in which I
can do it without the for loop.
I do it now like this (this algorithm appears to be corr...
2011 Jun 14
2
Need script to create new waypoint
...ssuming a constant movement during the time interval). The 'time distance' bewteen WP3 and WPnew is (120-73) 47 seconds and the 'time distance' between WPnew and WP4 is (153-120) 33 seconds (whereas total time interval between WP3 and WP4 is 80 seconds). WPnew (with coordinates Xnew,Ynew) should then be located at 80/33*100=41.25% from WP3: Xnew = X3 + (X4-X3)*41.25% and Ynew= Y3 + (Y4-Y3)*41.25%
2) Calculate the average location (average of x3,y3 and x4,y4), at which to create a new waypoint at 2 minutes.
3) A simpler alternative is that the location of the 'closer wayp...
2008 Dec 19
0
How to plot arrows for a PLS plot with ggplot2?
...Loadings plot. Here it is where my struggle comes from with ggplot2.
The Loadings are in this dataset!
> str(data2)
'data.frame': 4 obs. of 9 variables:
$ plsr1 : num 0.9522 0.2986 -0.0898 0.1561
$ plsr2 : num 0.2287 -0.9686 -0.1017 0.0105
$ xnew : num 0 0 0 0
$ ynew : num 0 0 0 0
Aparently with plain R is fairly simple, although I cannot override to
the previous plot.
>plot(data2$plsr1,data2$plsr2)
>arrows(data2$xnew,data2$ynew,data2$plsr1,data2$plsr2,lwd=2,length = 0.2, angle = 30)
How to do that with ggplot2 and override it to the previous score...
2009 Feb 03
1
Collapsing panel data
...t;", "", "B", "", "C")
x <- c(0.5, 0.2, 0.3, 0.1, 0.9, 0.4)
The empty lines "" always belong to the firm above. Now I want to collapse
the dataset so that each firm (A,B, C, etc) has one line only, using
summation.
So what I would like is
yNew <- c("A", "B", "C")
xNew <- c(1, 1, 0.4)
The problem I'm having is that each firm has a different number of entries
for x, so some like C have just one and others have ten or more, so I have
difficulty imagining how to use a loop in this case.
I'd be gre...
2005 Aug 08
1
bug found in predict.locfit in locfit package (PR#8057)
...fyxv=predict(fityxv,where="data")
######## Marginal distribution of gxv
# fit marginal distribution of y
fitxv=locfit(~x1+x2,alpha=0.5,deg=1)
gxv=predict(fitxv,where="data")
######## Prediction of fyxv and gxv
# new data
vx1=0.2
vx2=0.7
x1new=rep(vx1,ndat)
x2new=rep(vx2,ndat)
ynew=y
# marginal distribution of gxv for new data
newdata=data.frame(x1new,x2new)
gxvnew=predict(fitxv,newdata) #bug!!! gave the same values as gxv
# This bug can be avoid by setting new values into old variables
# then, we will get the new predicted values
# for example
x1=x1new
x2=x2new
gxvnew2=p...
2005 Oct 05
0
bug found in predict.locfit in locfit package ( PR#8057)
...Marginal distribution of gxv
> # fit marginal distribution of y
> fitxv=locfit(~x1+x2,alpha=0.5,deg=1)
> gxv=predict(fitxv,where="data")
>
> ######## Prediction of fyxv and gxv
> # new data
> vx1=0.2
> vx2=0.7
> x1new=rep(vx1,ndat)
> x2new=rep(vx2,ndat)
> ynew=y
>
> # marginal distribution of gxv for new data
> newdata=data.frame(x1new,x2new)
> gxvnew=predict(fitxv,newdata) #bug!!! gave the same values as gxv
>
> # This bug can be avoid by setting new values into old variables
> # then, we will get the new predicted values
> #...
2005 Sep 06
2
Predicting responses using ace
...acepack library. I Have a question: Is there a way to predict
new responses using ACE? What I mean is doing something similar to the
following code that uses PPR (Projection Pursuit Regression):
library(MASS)
x <- runif(20, 0, 1)
xnew <- runif(2000, 0, 1)
y <- sin(x)
a <- ppr(x, y, 2)
ynew <- predict(ppr, xnew)
Any help would be much appretiated, Thanks in advance,
Luis Pineda
2012 Nov 28
2
Error message R2Jags
...[i] +
b[6] * I2[i] +
b[7] * I3[i]
log(mu[i]) <- max(-20, min(20, eta[i]))
PRes[i] <- (Y[i] - mu[i]) / sqrt(mu[i]) #estimate residuals (=
observed - expected / sqrt(variance))
#Discrepancy measures (used for checking overdispersion)
YNew[i] ~ dpois(mu[i]) #New data
PResNew[i] <- (YNew[i] - mu[i]) / sqrt(mu[i])
D[i] <- pow(PRes[i], 2)
DNew[i] <- pow(PResNew[i], 2)
}
# Add up discrepancy measures
fit <- sum(D[1:N])
fit.new <- sum(DNew[1:N])
for (i...
2009 Apr 07
1
get optim results into a model object
Hello all, I have an optimization routine that is giving me good results,
but the results are not in the nice "model" format like "lm". How can I get
optim results into a model so that I can use the clever 'fitted',
'residuals', and 'summary' functions?
Using optim is the only way that I was able to make a model that
1) sums the betas to 1,
2)
2005 May 27
0
3D density estimation with library sm - no estimate returned
...00), ncol = 3), display =
"none")
> str(sm.density(matrix(rnorm(200),ncol=2),display="none"))
List of 10
$ eval.points: num [1:50, 1:2] -2.67 -2.57 -2.47 -2.38 -2.28 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:2] "xnew" "ynew"
$ estimate : num [1:50, 1:50] 3.76e-05 5.10e-05 7.57e-05 1.22e-04
2.05e-04 ...
$ h : Named num [1:2] 0.414 0.512
..- attr(*, "names")= chr [1:2] "" ""
$ h.weights : num [1:100] 1 1 1 1 1 1 1 1 1 1 ...
$ weights : num [1:100] 1 1 1 1 1 1 1 1 1...
2007 May 28
1
off-topic: affine transformation matrix
This may sound like a very naive question, but...
give two lists of coordinate pairs (x,y - Cartesian space) is there any simple
way to compute the affine transformation matrix in R.
I have a set of data which is offset from where i know it should be. I have
coordinates of the current data, and matching coordinates of where the data
should be. I need to compute the composition of the affine
2009 Aug 31
1
clarificatin on validate.ols method='cross'
Hi,
I was hoping to clarify the exact behavior associated with this incantation:
validate(fit.ols, method='cross', B=50)
Output:
index.orig training test optimism index.corrected n
R-square 0.5612 0.5613 0.5171 0.0442 0.5170 50
MSE 1.3090 1.3086 1.3547 -0.0462 1.3552 50
Intercept 0.0000 0.0000 -0.0040 0.0040