Displaying 6 results from an estimated 6 matches for "rowidx".
Did you mean:
rowid
2004 Jul 08
2
Getting elements of a matrix by a vector of column indice s
See if the following helps:
> m <- outer(letters[1:5], 1:4, paste, sep="")
> m
[,1] [,2] [,3] [,4]
[1,] "a1" "a2" "a3" "a4"
[2,] "b1" "b2" "b3" "b4"
[3,] "c1" "c2" "c3" "c4"
[4,] "d1" "d2" "d3" "d4"
[5,]
2003 Oct 27
2
how to select random rows ?
How can I select random subsets (rows!) from a data set ?
If I generate simple data set
> a <- data.frame(x=1:2, y = NaN, z = 2:1)
> a
x y z
1 1 NaN 2
2 2 NaN 1
I can select random subsets (colums) very easily using sample function:
> sample(a, 2)
z y
1 2 NaN
2 1 NaN
I expected that using transpose of a would do the same for rows, but I am
getting
rather unexpected
2017 Jun 18
3
R_using non linear regression with constraints
...9, 13, 17, 20 )
, y = c( 0, 11, 20, 29, 38, 45 )
)
myfun <- function( a, b, r, t ) {
a * b * ( 1 - exp( -b * r * t ) )
}
objdta <- expand.grid( a = seq( 1000, 3000, by=20 )
, b = seq( -0.01, 1, 0.01 )
, rowidx = seq.int( nrow( mydata ) )
)
objdta[ , c( "y", "t" ) ] <- mydata[ objdta$rowidx
, c( "y", "x" ) ]
objdta$tf <- factor( objdta$t )
objdta$myfun <- with( objdta
, myfun( a...
2017 Jun 18
0
R_using non linear regression with constraints
...0, 11, 20, 29, 38, 45 )
> )
>
> myfun <- function( a, b, r, t ) {
> a * b * ( 1 - exp( -b * r * t ) )
> }
>
> objdta <- expand.grid( a = seq( 1000, 3000, by=20 )
> , b = seq( -0.01, 1, 0.01 )
> , rowidx = seq.int( nrow( mydata ) )
> )
> objdta[ , c( "y", "t" ) ] <- mydata[ objdta$rowidx
> , c( "y", "x" ) ]
> objdta$tf <- factor( objdta$t )
> objdta$myfun <- with( objdta
>...
2017 Jun 18
0
R_using non linear regression with constraints
I ran the following script. I satisfied the constraint by
making a*b a single parameter, which isn't always possible.
I also ran nlxb() from nlsr package, and this gives singular
values of the Jacobian. In the unconstrained case, the svs are
pretty awful, and I wouldn't trust the results as a model, though
the minimum is probably OK. The constrained result has a much
larger sum of squares.
2017 Jun 18
3
R_using non linear regression with constraints
https://cran.r-project.org/web/views/Optimization.html
(Cran's optimization task view -- as always, you should search before posting)
In general, nonlinear optimization with nonlinear constraints is hard,
and the strategy used here (multiplying by a*b < 1000) may not work --
it introduces a discontinuity into the objective function, so
gradient based methods may in particular be