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

0
votes
0answers
12 views

hts package in R [migrated]

I want to use optimal comination method of hts package in r to get hierarchical forecasts with single exponential smoothing (SES) forecasting method, I read in the manual that avaialble forecast ...
0
votes
0answers
21 views

Repeated measures interaction with categorical and continuous predictors

I'm trying to do a repeated-measures analysis to determine the interactive effect of 2 continuous predictors (itss_c and ladder_c) on an outcome measure that was assessed at 3 points in time, but I'm ...
0
votes
0answers
46 views

Meta-analysis of percent relative to baseline in R using metafor package

I would like to conduct a meta-anaylsis in the context where I have studies available that measure a continuos variable at multiple time points (0, 1, 2, 3, 4, 5). Time 0 represents the baseline at ...
0
votes
2answers
56 views

If the model fits well, nothing can be done?

I am playing a data without any background information. First, I try multiple linear regression. The model fits well, since the $r^2$ is larger than 90%. I deleted several variables by AIC. The fits ...
0
votes
0answers
12 views

Dashed curve in simple R plot. Lty=2 does not seem to be working [migrated]

I am having trouble with getting a simple plot to return a dotted line (lty=2). This is a very elementary problem, but I can't seem to find the solution. I would greatly appreciate if someone could ...
0
votes
1answer
49 views

Should I just accept that data is strongly not normal when changing families for a Generalised Linear Model has not worked?

I initially tested my data with ANOVA, but upon finding it to be not normally distributed I tried a Kruskal test. This did not make any difference either, so I tried a GLM, taking into account the ...
3
votes
2answers
109 views

Difference between two variables

In my data set I have two variables: month (March or April) and wind direction (N, NE, E, SE, S, SW, W, NW). I have to know if there is a difference in wind direction between these months. What kind ...
1
vote
1answer
43 views

Normal distribution (R)

This is the graph of my variable after the $\sqrt[3]{x}$-transformation. After the transformation, I ran a Shapiro test and obtained a $p$-value of $0.004262$. Is it possible my transformed variable ...
1
vote
0answers
30 views

Model selection using AIC in Survival Analysis

As far as I know, the model with lowest AIC is said to be better. However, according to the R output below, the writer says, the model called wei is better, whose ...
1
vote
1answer
30 views

Linear mixed effect model with repeated measures using lmer

Background I think I am close to the error structure I want for random effects but not sure about some parts of it. I am carrying an experiment on wheat plots in a field to measure the increase in ...
0
votes
1answer
41 views

How to estimate an ARMA with non consecutive lag in R?

Lets say I have an ARMA with an AR(1,4) and an MA(1). Update To be more specific the model to be estimated is: $$y_t = \rho_1 y_{t-1} + \rho_4 y_{t-4} + \epsilon_t + \theta_1 \epsilon_{t-1}$$ ...
-2
votes
1answer
28 views

Reduce the polynomial terms in logistic regression (glm)

I've three categorical variables A, B and C with 5 levels each. The model I'm trying to fit is glm(Y~A+B+C, family=binomial()) How can I remove the higher order ...
1
vote
1answer
35 views

Equation to get an ordered logit model from R into Excel

Original I have fitted an ordered logistic regression in R using the polr function, but I am having some trouble bringing the model coefficients into Excel and ...
0
votes
0answers
16 views

Adjust confidence ribbon in regression plot in ggplot2(R) [migrated]

I am plotting a regression line with confidence intervals in ggplot2. How can I adjust the code (see below) that there is no shaded area indicating the confidence interval but just a dotted line for ...
1
vote
0answers
17 views

Transforming panel data in R/Excel [migrated]

I have following dataset, where WEEK specifies a week in a certain year (W03046 is week 46 in 2003) and MSBRAND stands for the marketshare of a specific brand in the corresponding week: ...
2
votes
1answer
79 views

Why are the signs of my coefficients are different?

My code is: library(survival) attach(veteran) survreg(Surv(time,status)~karno+diagtime+age+prior+trt ,dist="w") My analysis and the one in a book are as follows: ...
0
votes
0answers
14 views

Ranking predictor variables based on their importance/impact in r

This question has two parts. I am doing a logistic regression. The predictor variables are a mixture of categorical and continuous. I ran glm and out of the 80 predictors about 36 came out to be ...
0
votes
0answers
31 views

How can I rank predictor variables based on their importance/impact in R?

I am doing a logistic regression. The predictor variables are a mixture of categorical and continuous. I ran glm and out of the 80 predictors about 36 came out to be significant based on the p value. ...
2
votes
1answer
32 views

Residuals from lowess curve

I am trying to obtain the residuals from a lowess fit. I’m using the lowess( ) function. Is there a way to do this?
2
votes
0answers
36 views

tobit two-stage in R

I'm working with a dependent variable $y_i \in [0,1]$. I have a single endogenous explanatory variable $w_i \in [0, 1]$ with corresponding instrument $z_i \in \{0,1\}$. Suppose further that I have a ...
1
vote
1answer
42 views

How to read results of the Dunn Test from R

How do I read the results from a Dunn test? Specifically, what do the values in the table below tell me? I have non-parametric data in 4 groups, and I first did a Kruskal-Wallis test to confirm that ...
-1
votes
0answers
6 views

Year to Year-Month-Day format [migrated]

I have a datafile in the following format: ...
1
vote
0answers
15 views

3-way repeated mesures ANOVA

I conducted reaction-time experiment with three factors - set size (4, 16, 64), presense of the target (present, absent) and the third factor with two levels (C, F). After that I ran a repeated ...
0
votes
0answers
36 views

Computing significance of a hypothesis test

I am constructing a hypothesis test on a distribution $Bin(10,p)$, $H_0:p=0.5$ vs $H_1:p=0.55$. I used R programming and I found the significance level when critical value is 8 to be 0.0546875. Why ...
7
votes
2answers
209 views

Is there a way to force a relationship between coefficients in logistic regression?

I would like to specify a logistic regression model where I have the following relationship: $E[Y_i|X_i] = f(\beta x_{i1} + \beta^2x_{i2})$ where $f$ is the inverse logit function. Is there a ...
2
votes
1answer
44 views

How can I calculate p-values in R?

I am trying to construct a hypothesis test for the variance of two populations. My test statistic is $F=$${\sigma_b^2}$/${\sigma_A^2}$. I want to implement this as a function in R so I computed: ...
0
votes
0answers
14 views

Apply conjugate gradient method to find vector with constraint

I have sample data of 10 stocks: a<-replicate(10,rnorm(100)) I am trying to find a weight vector that minimizes the variance of returns. To do this I have a starting weight vector W1 and I am ...
0
votes
1answer
15 views

vglm: Error in vglm.fitter, due to matrix dimension?

I've looked to other Error in vglm.fitter-related posts but they don't seem (or I cannot) related to this one. This the error I get when running vglm for multinomial regression (classification): ...
0
votes
2answers
32 views

Adding a value to each element of a column in R [closed]

I would like to add a value to each element of a column For example: 1 2 3 4 5 to which I would like to add a value, let's say 5. The result I am after is: 6 7 8 9 10 It shouldn't be too hard ...
2
votes
0answers
87 views

Visualize the difference from target value with bar charts [migrated]

I am trying to visualize the offset of a time series from its baseline value using bar charts from R's gglot2 package. For instance, take the following synthetic data: ...
0
votes
1answer
41 views

confidence intervals best through direct calculation or R's confint funtion

I am interested in pairwise comparison of means, through the calcul of confidence intervals (CI) of the difference between two given sample's means. However, CI calculated directly from each sample, ...
1
vote
0answers
41 views

Linear regression with a delay : $R(t)= a S(t-\delta) + \epsilon$

$R(t)$ corresponds to soil respiration values in function of the time $S(t)$ corresponds to solar radiation values in function of the time $R(t) = a S(t-\delta) + \epsilon$ How calculate the ...
0
votes
0answers
14 views
0
votes
2answers
22 views

Kernel SVM on sparse data

I have a sparse dataset where a lot of the columns (features) contain mostly zero values. Class labels are multiple discrete categories (10 classes to be precise). I'm wondering if this should trouble ...
3
votes
1answer
48 views

Time Series Forecast: Convert differenced forecast back to before difference level

I am using R and I need an easier way to produce forecasts of data at the original level based on forecasts using differenced data. The situation, in more detail, is this: I am using several ...
-1
votes
1answer
31 views

Perform two-way ANOVA (one observation per mean) in R?

How do we do two-way ANOVA (one observation per mean), as testing H_A in Section 8.5 in Seber and Lee's Linear Regression Analysis, in R? Note that the linear model for this case doesn't have ...
0
votes
0answers
14 views

Group mean versus subject means in hierarchical bayesian analysis

I'm using stan in R to estimate several parameters of interest. Doing so requires using hierarchical models. In some basic testing of what I'm trying to do, I got results where the estimates of all ...
18
votes
5answers
283 views

Color and line thickness recommendations for line plots

Much has been written about color blind-friendly color choices for maps, polygons, and shaded regions in general (see for example http://colorbrewer2.org). I have not been able to find ...
0
votes
0answers
4 views

using character R function [migrated]

I'm creating a function in R where I'm asking a letter (or a string). Here is an example with a first function: fun.1<-function(a=2,b=3,c=4) return(a+b^2+c^3) ...
1
vote
0answers
25 views

Interpreting summary output in R [duplicate]

I'm fitting a linear model to a dataset. I've reduced the model from 7 variables to 3 and as part of that I've transformed one of my variables (wt) in order to get a better fit. For my final model, ...
0
votes
0answers
14 views

How to change the color and width of lines with par function [migrated]

I have a question about the par function in R. I want to change the color and/or width of a line in a graph with par function. (I am using par function because the gaps.plot command below does not ...
0
votes
0answers
12 views

Parameter estimation using lmom package

As a part of my risk management job, I need to try to fit various distributions to loss data. I have been using the lmom package in R for estimating parameters for ...
2
votes
0answers
46 views

ANOVA using count data

I'd like to perform a two-way ANOVA on count data. I was told to first fit a GLM and then do the ANOVA. My first problem is that ...
1
vote
2answers
54 views

Which test to use to check the difference between samples of percentages?

I have data measured from 14 samples between two conditions. I want to check difference between them. But the data is normalised and is in terms percentage (0-100). For example ...
0
votes
1answer
32 views

Failing to include interaction terms

If you fail to include for interaction terms in your model if interaction exists. Would your $R^{2}$ be less then what it would be if you included the interaction terms $R^{2}$ ?
1
vote
0answers
15 views

serial correlation, homocedasticity tests for non linear and non parametric regression

For linear and parametric regression there are multiple tests where variables and residuals are used by means of performing a linear regression function to test serial correlation of regression errors ...
0
votes
0answers
19 views

SVM predictions of timeseries (forex) data are shifted

I am trying to build timeseries prediction SVM (regression variety) for forex data based on lagged close data. And I am using R. Please see the simple code below and resulting graph, using e1071 ...
1
vote
0answers
42 views

Converting numbers in linear space to binary using sigmoid in R

I'm running a binary prediction using a supervised topic modeling package in R (lda package, using slda.predict function). The ...
1
vote
0answers
19 views

Specifying a structural equation model with sem

I'm new to sem package and sem analyses, so this is probably very basic, although I was not able to solve it myself reading some other similar posts. I was trying to specify a structural equation ...
2
votes
0answers
48 views

How to work with an improper uniform prior in R?

I'm coding some Bayesian bandits algorithms for exponential families and for the case when my rewards are normally distributed, I need to use an improper uniform prior. Is there any way to represent ...