Ar ! What a pity, I have not seen it ! Many thanks !
Le mercredi 18 septembre 2019 à 19:07:42 UTC+2, peter dalgaard
a écrit :
Redefining n is probably not a good idea...
[...snip...]
> m <-runif(n, 0, 5)
> n <-rnorm(n, 2, 3)
Oops! n is now a vector of length 2000.
[...snip...]
>
De: varin sacha via R-help
Enviado: martes, 17 de septiembre de 2019 21:49
Para: R-help Mailing List
Asunto: [R] Not the same length
Dear R-helpers,
Doing dput(x) and dput(y_obs), the 2 vectors are not the same length (1800 for
y_obs and 2000 for x)
How can I solve the problem ?
Here is the repro
Redefining n is probably not a good idea...
[...snip...]
> m <-runif(n, 0, 5)
> n <-rnorm(n, 2, 3)
Oops! n is now a vector of length 2000.
[...snip...]
> y_obs <- y_model +c( rnorm(n*0.97, 0, 0.1), rnorm(n*0.03, 0, 0.5) )
now length(n*0.97) == 2000 > 1, so rnorm(n*0.97, ...) gets you a length
Dear Peter Dalgaard,
Really appreciated, but my code does not work. There is still a problem ! Here
below the reproducible example with 20 variables
library(mgcv)
library(earth)
n<-2000
x<-runif(n, 0, 5)
z <- rnorm(n, 2, 3)
a <- runif(n, 0, 5)
b <- rnorm(n, 2, 3)
c <- runif(n, 0, 5)
d <
Um, I think not... The mean of the last 200 observation won't line up with the
x and z.
Possibly, if what you want is the last 200 obs to have a different variance,
y_obs <- y_model + c(rnorm(0.9 * n, 0, 0.1), rnorm(0.1 * n, 0, 0.5))
or
y_obs <- rnorm(n, y_model, rep(c(0.1, 0.5), c(.9 * n, .
On 9/17/19 2:08 PM, David Winsemius wrote:
On 9/17/19 1:35 PM, varin sacha wrote:
Many thanks David, it perfectly works.
Now, one last think.
If I want my R code here below to run let's say B=500 times and at
the end I want to get the average for the MSE_GAM and for the
MSE_MARS. How can I
On 9/17/19 1:35 PM, varin sacha wrote:
Many thanks David, it perfectly works.
Now, one last think.
If I want my R code here below to run let's say B=500 times and at the end I
want to get the average for the MSE_GAM and for the MSE_MARS. How can I do that
?
The `replicate` function is desi
obs <- c( rnorm(n*0.9, y_model, 0.1), rnorm(n*0.1, y_model, 0.5) )
then y_obs:
> length(y_obs)
[1] 2000
De: varin sacha via R-help
Enviado: martes, 17 de septiembre de 2019 21:49
Para: R-help Mailing List
Asunto: [R] Not the same length
Dear R-helpers,
Doing dput(x) and dput(y_ob
Many thanks David, it perfectly works.
Now, one last think.
If I want my R code here below to run let's say B=500 times and at the end I
want to get the average for the MSE_GAM and for the MSE_MARS. How can I do that
?
library(mgcv)
library(earth)
n<-2000
x<-runif(n, 0, 5)
z <- runif(n, 0,
It depends on what you want to do, which is likely not what you do do
You might be looking for
y_obs <- ifelse(runif(n) < .9, rnorm(n, y_model, 0.1), rnorm(n, y_model, 0.5))
-pd
> On 17 Sep 2019, at 21:48 , varin sacha via R-help
> wrote:
>
> Dear R-helpers,
>
> Doing dput(x) and dput
On 9/17/19 12:48 PM, varin sacha via R-help wrote:
Dear R-helpers,
Doing dput(x) and dput(y_obs), the 2 vectors are not the same length (1800 for
y_obs and 2000 for x)
How can I solve the problem ?
Here is the reproducible R code
# # # # # # # # # #
library(mgcv)
library(earth
Dear R-helpers,
Doing dput(x) and dput(y_obs), the 2 vectors are not the same length (1800 for
y_obs and 2000 for x)
How can I solve the problem ?
Here is the reproducible R code
# # # # # # # # # #
library(mgcv)
library(earth)
n<-2000
x<-runif(n, 0, 5)
y_model<- 0.1*x^3 -
12 matches
Mail list logo