Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer (b) is not *just* about how to program in `R`.

learn more… | top users | synonyms

1
vote
1answer
30 views

Combinef in R HTS package- constrain to keep forecasts positive?

When using the combinef function from Rob Hyndman's very useful hts package for forecasting hierarchical and grouped time series, there does not seem to be a way to constrain the optimally combined ...
0
votes
0answers
16 views

Specifying a glmm for panel data

I'm trying to predict counts based on variables sampled on a monthly basis as well as a few that are not related to time. In several places I've read that the MCMCglmm package in R would be ...
0
votes
1answer
31 views

Multivariate Time Series

I am trying to learn multivariate time series using R. I have two time series and I want to see if I could use one of those to predict the other one, and after that check if the model holds or there ...
0
votes
0answers
9 views

Select range of dates above and below another date [migrated]

Consider these small dataframes a and b: ...
0
votes
0answers
28 views

How to model non-linear time courses with nlme

I have some time course data which plotted looks like this: I am trying to fir a model to it using nlme.lme(). I am interfacing with R via RPy, and using the ...
1
vote
2answers
41 views

Is it important to convert “integer” variables (with 0 or 1 values) to factors?

I am working on a high-dimensional dataset (1776 variables). When I read the csv file, R loads variables (with 0 or 1 values) as class of "integer". Is it important to convert these variables to ...
1
vote
1answer
32 views

How to get the value of Mean squared error in a linear regression in R

Let a linear regression model obtained by the R function lm would like to know if it is possible to obtain by the Mean Squared Error command. I had the FOLLOWING output of an example ...
0
votes
0answers
8 views

Finding rows of a matrix meeting some conditions [migrated]

I want to find the rows that contain given column values. The first which() returns the expected 3 row numbers but last statement returns only 1 instead of 1 2 4 as I expected. This example ...
1
vote
0answers
37 views

How does the cubic spline basis exactly look like

By the definition I'll have (1) $S(x)=\begin{cases} S_0 = a_0x^3 + b_0x^2 + c_0x + d_0, & \text{if }t_0\le x\le t_1\\ .....\\ S_{k} = a_kx^3 + b_kx^2 + c_kx + d_k, & \text{if ...
0
votes
0answers
16 views

Robust Estimator for GARCH in R programming

I just want to know if R programming provides estimator estimation beside QMLE, because I want to compare these estimators' performance toward outliers. What package provides a function for this ...
0
votes
1answer
23 views

Partial least squares regression for categorical factor in R

I adjust the partial least squares regression for one categorical factor (2 levels – be or nottobe) with with the ...
2
votes
0answers
12 views

Where can I find the limiting distribution of the Kolmogorov-Smirnov distance in R? [migrated]

While doing an experiment on importance sampling, I simulate values of Kolmogorov-Smirnov distances $$ D_n = \max_x |\hat{F}_n(x)-F(x)| $$ where $n$ is the size of the original importance sample and ...
0
votes
0answers
15 views

How to analyse individual consistency from three non-normally distributed variables?

I would like to know if individuals were consistent across three different days. I measured the latency of individuals for a maximum of ten minutes. Many individuals had a latency of 0 and some ...
6
votes
4answers
177 views

Help creating a chart to show categorical data over time

The scenario: Over a course of 10 minutes 2 security guards patrol a floor and have their movement tracked. They can either be on the left or the right side of the floor, and within each side of the ...
-2
votes
0answers
51 views

Method to identify samples lying outside the normal distribution

In my previous questions I was looking for a method identify samples that had a variability significantly higher than the rest of my dataset. Methods to determine reliability of measurements using ...
1
vote
2answers
80 views

Forest plot for meta-analysis displaying the mean ES with and without outliers

I am conducting a meta-analysis and am trying to produce a forest plot displaying the mean weighted effect size with and without the outliers. I looked on so many websites and tried a lot of syntaxes, ...
0
votes
1answer
63 views

Data Acquisition in R [closed]

R is good at processing data. It is an analytic turbo-ginsu. So LabVIEW is great at getting data. It plugs into anything with electrodes. MatLab has simulink. There are toolboxes for data ...
0
votes
0answers
14 views

Conditional calculating the numbers of values in column with R [migrated]

have two vectors: x <- c(1,1,1,1,1, 2,2,2,3,3, 3,3,3,4,4, 5,5,5,5,5 ) y <- c(2,2,1,3,2, 1,4,2,2,NA, 3,3,3,4,NA, 1,4,4,2,NA) Here ...
0
votes
0answers
9 views

SSCP in analysis of covariance

I want to use analysis of covariance in R. The model is $y_{ij} = \mu + t_i + r_j + b(x_{ij} - \bar{x}) + e_{ij} $ In R it is possible to get Ryy, Tyy, Eyy, SSE as well as b and adjusted treatment ...
0
votes
1answer
35 views

using cluster information in multiple imputation

i need to impute a dataset all categorical variables before doing analysis. I can just simply impute with mode of all data or a variable. I belief that better option will be to classify the subjects ...
3
votes
1answer
29 views

Getting the equation from R's lm when using a product

Similar to this question: How to translate the results from lm() to an equation? in which the top voted answer said how to get the form of an equation from ...
3
votes
2answers
91 views

Grouping sequential values in R

I have a list of numbers I need to group by similarity (differences being 1 between each). For example, in a list of [198, 202, 207, 218, 219, 220], 190 would be put into a list, 202 would be put into ...
3
votes
1answer
30 views

How to plot correlation coefficients from multiple regressions while leaving out some of the variables from the plot?

Lets say that I have "y" that I want to model with linear regression. "x" and "z" are the things I'm interrested in showing folks, but I also have things that I want to adjust for, but not really show ...
0
votes
0answers
17 views

building a decision tree after association rules

I built association rules using R Arules package. Then I filtered those rules and kept rules that have a specific variable on RHS. That variable is my Y variable. In entire dataset, my variable occurs ...
0
votes
0answers
10 views

What are, in the r function glm, the families “quasi” and “inverse”? [migrated]

The glm function in R takes a "family" argument, which can also be set to "quasi" or "inverse". I couldn't find anything in the docs...
0
votes
1answer
39 views

What is the z-value of glm model parameters?

I know what the z-value of a single observation is, that is explained in Wikipedia. But what is the z-value of a parameter in a glm model?
1
vote
0answers
16 views

error structure in Generalized linear models when y is continuous data and errors not normally distributed

Lets say I have continuous y and x variable and I run a linear regression: mdl1<-lm(y ~ x) A generalised linear model should also give me the same parameters ...
0
votes
0answers
44 views

(Spatial) distance between cluster means

I'd like to cluster points based on a distance criteria. As I want to cluster spatial points I am using euclidean distance and a hierachical cluster approach. In a final step I'd like to cut the ...
0
votes
0answers
9 views

Obtaining Cohen's d from z-test statistic

After an ANOVA, I run post-hoc tests with the glht function in the multcomp package. glht ...
0
votes
1answer
35 views

Repeated-measures, crossover analysis using linear mixed model in R

I have a data set that I am attempting to analyse in R and I am relatively new to the environment. My full data set contains 7 subjects (represented by Subject), that all receive 3 treatments ...
0
votes
1answer
38 views

Calculating hypergeometric probability with approximations

I'm essentially trying to reproduce the dhyper function in R using !n ~ gamma(n+1). Why does this approach not work for large ...
1
vote
1answer
68 views

Analysis of Customer satisfaction surveys

I have customer feedback data about 2-3 products from 100 customers. Number of questions are around 160. I have data in excel format. Header row contains the question and row below contains the ...
1
vote
0answers
28 views

Odds ratios from logistic regression on subsets of data using R

I have 15 subjects each with 200 trials & I'd like to run separate regressions for each subject. If I just run the regression on the whole dataset I am able to generate odds ratios / confidence ...
1
vote
0answers
22 views

fitting an exponential decay onto a regression line

I have data for adherence to medicines which follows a downward linear trend for about 6 months (from 100%) and then plateaus at about 50%. Another way of describing it is by saying that adherence ...
1
vote
0answers
16 views

How to obtain estimates for all levels in a mixed effects model that uses effect (deviation) coding?

I am running a binomial mixed effects logistic regression in R using glmer for a sociolinguistics project. I was asked to used deviation (effect) coding. From what ...
0
votes
0answers
8 views

custom axis labels plotting a forecast in R [migrated]

I'm trying to get some sensible labels on a forecast. Here's my code: ...
0
votes
1answer
20 views

testing for mediation of interactions

I am somewhat familiar with various ways of testing mediation for factors in different types of regression analysis. (I'm using R and currently working with a multilevel binary logistic regression.) ...
2
votes
1answer
37 views

Jeffries Matusita distance for 14 variables

I wish to perform Jeffries-Matusita distance on 14 spectral bands. Is there anyone who can help with how it is done in R? Thank you.
0
votes
3answers
120 views

using random forest for missing data imputation in categorical variables ( in R)

I have following type of associated data. The following example step to generate associated variable. p number of variables and n is number of observations. ...
1
vote
1answer
43 views

Survival analysis in R with left-truncated data

I am doing a survival analysis in R with the survival package. I think I am working with left-truncated data, but I'm not entirely sure how to handle it. I have a ...
1
vote
0answers
35 views

difference in results of mixed effects model in nlme and lmer4 package

Can anyone please tell me why the results of random slope model is different for the same dataset when I use lme and lmer. I first fitted a random intercept model as follows using both lme as well ...
2
votes
1answer
47 views

Exact logistic regression, R, and elrm: data formatting and output

I use SPSS, but am forced to use R for exact logistic regression. So I'm brand new to R (and hating it so far) and also new to logistic regression. I've read the original elrm paper and looked at ...
0
votes
0answers
49 views

Predicting conditional expected lifetime by Cox model in R

I'm using a Cox proportional hazards model, estimate the hazard rate for Levamisole relative to 5-FU, adjusting for Age and Sex. ...
2
votes
3answers
27 views

Kolmogorov-Smirnov of two heart rate samples

I'm accumulating a lot of vital signs from emergency department patients, and would like to assess if different features yield significantly different distributions. Eg. for heart rate I have 888.424 ...
1
vote
0answers
7 views

How to use Levene's test on a data frame in R [migrated]

Say I have a data frame with two columns, height (in inches) and sex (Male or Female) and I want to run levene's test to see if the variance is the same for Male and Female height. How would I do ...
7
votes
1answer
137 views

Combining data from different sources

I want to combine data from different sources. Let's say I want to estimate a chemical property (e.g. a partitioning coefficient): I have some empirical data, varying due to measurement error around ...
2
votes
0answers
44 views

How can I make 2-way ANOVA (Type I, II and III) with R?

I have the following data with factor 1 (A, B and C) and factor 2 (D and E): $$ \begin{array}{ccc} \hline & D & E\\ \hline A & 68 & 59\\ & 65 & 57\\ & 63 & 54\\ ...
0
votes
1answer
33 views

randomSurvivalForest in R

I'm using the randomSurvivalForest package for R, version 3.6.4. I have been using it for a project for a while, with no problem. However, now I have added some additional predictors to my dataset, ...
4
votes
2answers
179 views

cubic relationship after linear relationship

Sorry for my title, but I really don't know how to describe this question. I am fitting a linear regression in R now, and I find that there is one parameter showing linear relationship before certain ...