Have you tried putting the a,b, and c column names you are passing in quotes
i.e. as strings? Currently your function is expecting separate objects with
those names.
The select function itself can accept unquoted column names, as can others in
R, because specific processing they do in the backg
Hi Stefano
I think either of these does what you need...
1: This gets the interval column as you want it, but utilises the lubridate
package:
library(lubridate)
mydf$interval = ceiling_date(mydf$data_POSIX, unit="30 minutes”)
2: Alternative in base R is a bit more long winded: convert the da
A bit quicker:
t(pmin(t(somematrix), UB))
> On 27 May 2020, at 20:56, Bert Gunter wrote:
>
> Jeff: Check it!
>
>> somematrix <- matrix(c(1,4,3,6,3,9,12,8,5,7,11,11),nrow=3,ncol=4)
>> UB=c(2.5, 5.5, 8.5, 10.5)
>> apply( somematrix, 2, function( x ) pmin( x, UB ) )
> [,1] [,2] [,3] [,4]
>
I am having difficulty fitting a mgcv::gamm model that includes both a random
smooth term (i.e. 'fs' smooth) and autoregressive errors. Standard smooth
terms with a factor interaction using the 'by=' option work fine. Both on my
actual data and a toy example (below) I am getting the same error
When i increments to 6 (during the fifth iteration) the subsequent test of
x[i]<=5 will produce an error since x has only five elements.
> On 31 Mar 2018, at 14:45, Henri Moolman wrote:
>
> Could you please provide help with something from R that I find rather
> puzzling? In the small program b
I am trying to test out several mgcv::gam models in a scalar-on-function
regression analysis.
The following is the 'hierarchy' of models I would like to test:
(1) Y_i = a + integral[ X_i(t)*Beta(t) dt ]
(2) Y_i = a + integral[ F{X_i(t)}*Beta(t) dt ]
(3) Y_i = a + integral[ F{X_i(t),t} dt ]
I am trying to test out several mgcv::gam models in a scalar-on-function
regression analysis.
The following is the 'hierarchy' of models I would like to test:
(1) Y_i = a + integral[ X_i(t)*Beta(t) dt ]
(2) Y_i = a + integral[ F{X_i(t)}*Beta(t) dt ]
(3) Y_i = a + integral[ F{X_i(t),t} dt ]
Any of the usual rank correlation methods should be fine if you're expecting a
monotonic relationship e.g. Spearman's rho or Kendall's tau.
> On 1 Sep 2017, at 21:25, merlinverde...@infomed.sld.cu wrote:
>
> I would be very grateful if you would tell me how I can find the degree of
> correlatio
The returned values are in the list you assign to test_data, the original x and
y are not modified, i.e the returned value for x will be test_data[[1]] and for
y will be test_data[[2]]. Using the same variable names in the function and
test is perhaps what is leading to confusion.
> On 28 Jul
Is res.path usually empty? If the res.path directory is empty (i.e.
dir(res.path) is an empty vector) the file.remove operation will remove the
directory. This behaviour is documented in the help for file.remove. When
your subsequent function tries to write to that directory it does not exist
Would be grateful for advice on gam/bam model selection incorporating random
effects and autoregressive terms.
I have a multivariate time series recorded on ~500 subjects at ~100 time
points. One of the variables (A) is the dependent and four others (B to E) are
predictors. My basic formula i
This does the summation you want in one line:
#create example data and column selection
d = as.data.frame(matrix(rnorm(50),ncol=5))
cols = c(1,3)
#sum selected columns and put results in new row
d[nrow(d)+1,cols] = colSums(d[,cols])
However, I would agree with the sentiments that this is a bad i
If you are strict about your data formatting then the following is a fast way
of calculating the differences, based on reshaping the data column:
A = matrix(mydata$rslt, nrow=2)
data.frame(exp=1:ncol(A), diff=A[2,]-A[1,])
alternatively, if the 'exp' values are not guaranteed to be sequential you
Effectively you want a circulant matrix but filled by column.
Example input vector and number of columns
x = c(1:8,19:20)
nc = 5
For the result you specifically describe, the following generalises for any
vector and any arbitrary number of columns 'nc', padding with zeros as
necessary.
matrix
I have a (unbalanced) dataset of time series collected across several subjects
(n~500, ~6 observations). I would like to model the overall smooth time
trend of a variable and how this trend differs by various categorical factors,
with the subject as a random effect.
My baseline model
m1
15 matches
Mail list logo