instruction
stringlengths
9
38.7k
In R there is a function nlm() which carries out a minimization of a function f using the Newton-Raphson algorithm. In particular, that function outputs the value of the variable code defined as follows: code an integer indicating why the optimization process terminated. 1: relative gradient is close to zero, current ...
I create SAS output in .rtf format and the File Download warning pops up each time. I need to turn this off for all files that I create. How?
I was looking at howto figure out the optimal lag order for an ADF-test when I came across this PPT presentation. There are two examples of a ADF-test model reduction, one on p23 and one on p36. I have two questions: How do I come up with the F numbers of the reduction? For example, on p23 it says "F(1,487) = 0.92201 ...
I have fitted the ARIMA models to the original time series, and the best model is ARIMA(1,1,0). Now I want to simulate the series from that model. I wrote the simple AR(1) model, but I couldn't understand how to adjust the difference within the model ARI(1,1,0). The following R code for AR(1) series is: phi= -0.7048 ...
It is easy to produce a random variable with Dirichlet distribution using Gamma variables with the same scale parameter. If: $ X_i \sim \text{Gamma}(\alpha_i, \beta) $ Then: $ \left(\frac{X_1}{\sum_j X_j},\; \ldots\; , \frac{X_n}{\sum_j X_j}\right) \sim \text{Dirichlet}(\alpha_1,\;\ldots\;,\alpha_n) $ Problem What hap...
I just ran a vendor-supplied program that converts data from their proprietary binary format to what they call a "Matlab format". There are two resulting files from the conversion, a "filename.dat" and a "filename.m". The "filename.m" file seems to have column heading information in it. The second "filename.dat" file i...
Why continue to teach and use hypothesis testing (with all its difficult concepts and which are among the most statistical sins) for problems where there is an interval estimator (confidence, bootstrap, credibility or whatever)? What is the best explanation (if any) to be given to students? Only tradition? The views wi...
/edit: To clarify: The mtable function from the memisc package does exactly what I need, but unfortunately does not work with arima models. Similar to this question: I have multiple Arima models, some of which I've also fit with dependent variables. I'd like an easy way to make a table/graph of the coefficients in each...
In order to test the Matrix package in R, I ran the following piece of code: library(Matrix) p <- 50; n <- 500 a0 <- sample(1:(n*p), n*p*0.1) d1 <- (a0-1) %% n d2 <- floor((a0-d1)/n) d0 <- cbind(d1+1, d2+1) x0 <- Matrix(0, n, p, forceCheck=TRUE) x0[d0] <- rnorm(n*p*0.1, 10, 1) x1 <- matrix(rnorm(n*p), n, p) fx01 <- f...
X is the weight of a baby when born (in gram). If the distribution of X is N(3315, 575) and Y is the number of babies with weight lower than 2719 in a random sample of 25, then P[Y≤4] is about...? I'm trying to figure how to solve this. What kind of formula do I use? I suppose N is a normal distribution, that 3315 is t...
My problem is this: There are 52 people divided into 5 groups: A, B, C, D, and E. From stage 1 to stage 2, they either stay in the same groups, or change groups. The following table shows how many people change from their stage 1 group to stage 2 group for all pairs. Stage 1 Stage 2 Group A ...
I'm trying to figure out the best way of creating groups in a dataset with many dimensions. I have 1000 measurements, and each measurement has 40 dimensions. The measurements are of neighborhoods with physical and socio-economic data. For example I have measures like the number of people in each area, the population de...
This question might sound very broad, but here is what I am looking for. I know there are many excellent books about econometric methods, and many excellent expository articles about econometric techniques. There are even excellent reproducible examples of econometrics, as described in this CrossValidated question. In ...
This was inspired by Efficient online linear regression, which I found very interesting. Are there any texts or resources devoted to large-scale statistical computing, by which computing with datasets too large to fit in main memory, and perhaps too varied to effectively subsample. For example, is it possible to fit ...
If I have a dataset of $N$ pairs ($x_i$,$y_i$) where each $y_i$ has an individual error $\sigma_{y_i}$, I can incorporate this into regression by using the inverse of this as weights. If I now do logarithmic regression $\ln y_i = b_0 + b_1\,\ln x_i + \epsilon_i$, how do I incorporate now the errors? Are the weights jus...
I want to fit a multilevel GLMM with a Poisson distribution (with over-dispersion) using R. At the moment I am using lme4 but I noticed that recently the quasipoisson family was removed. I've seen elsewhere that you can model additive over-dispersion for binomial distributions by adding a random intercept with one lev...
How do I carry out a repeated measures analysis using R?
The geometric mean is the appropriate measure of central tendency for log-normally distributed variables. However, the arithmetic mean still has some use in relation to log-normal variables - in inferring totals from survey data, for instance. It is my understanding that the arithmetic mean of the sample of a log-norma...
Background I have a variable with an unknown distribution. I have 500 samples, but I would like demonstrate the precision with which I can calculate variance, e.g. to argue that a sample size of 500 is sufficient. I am also interested in knowing the minimum sample size that would be required to estimate variance with a...
Context: A sample of people were asked to provide ratings of their impression of jeepneys using a Likert Scale. Age, gender, household income, and so on was also obtained. Dangerous: strongly agree; agree; neutral; disagree; strongly disagree Convenient: strongly agree; agree; neutral; disagree; strongly dis...
I have the pdf $$f(y ; \theta) = \frac{1}{\theta} \exp( \frac{-y}{\theta}), \ y > 0$$ and I'm supposed to determine if the following two estimators are unbiased or not: $ \hat \theta = nY_{min} $ and $ \hat \theta = \frac{1}{n}\sum_{i=1}^n Y_i $. I'm running into some problems because when I try to find the expected ...
Is linear regression only suitable for variables with a normal distribution? If so, is there an alternative nonparametric test to test mediation or moderation?
I have a data set with a range of 0 to 65,000. The vast majority of data points (it is a huge sample) are concentrated between 0 and 1000. There is only one point that has 65,000. I want to plot this using a semi-logarithmic plot. However, I would like the graph to have around 50 points. If I use scales like 2,4,6...
Suppose I will be getting some samples from a binomial distribution. One way to model my prior knowledge is with a Beta distribution with parameters $\alpha$ and $\beta$. As I understand it, this is equivalent to having seen "heads" $\alpha$ times in $\alpha + \beta$ trials. As such, a nice shortcut to doing the ful...
Given a set of data (~5000 values) I'd like to draw random samples from the same distribution as the original data. The problem is there is no way to know for sure what distribution the original data comes from. It makes sense to use normal distribution in my case, although I'd like to be able to motivate that decisio...
I ran across this density the other day. Has someone given this a name? $f(x) = \log(1 + x^{-2}) / 2\pi$ The density is infinite at the origin and it also has fat tails. I saw it used as a prior distribution in a context where many observations were expected to be small, though large values were expected as well.
Why is it that "missing data" and "outliers" can affect the performance of least square estimation?
This question may have been asked before, but I couldn't find it. So, here goes. From about 3000 data points that can be characterized as "wins" or "losses" (binomial), it turns out that there are 52.8% dumb luck wins. This is my dependent variable. I also have some additional data that may help in predicting the a...
In Meta analysis, how to interpret the Egger’s linear regression method intercept (B0) 10.34631, 95% confidence interval (1.05905, 19.63357), with t=3.54535, df=3. The 1-tailed p-value (recommended) is 0.01911, and the 2-tailed p-value is 0.03822. I am a medical doctor. *Updated* The data are comparison of Regions 1 a...
Is there a package or library that can help me suggest a formula given the independent variables which will work well in glm, for example this formula can be something like x^2+log(y)+Z, it does not necessarily need to be the standard linear model x+y+z in order to explain a variable.
Hey guys. I got two images from video frames. They have a certain portion of overlap. After warping one of them, I'm currently trying to blend them together. In other words, I would like to stitch them together. But I don't know how to accomplish that. Can anybody please give me some help? Thank you! Let's say the ima...
While preparing for a talk I will give soon, I recently started digging into two major (Free) tools for interactive data visualization: GGobi and mondrian - both offer a great range of capabilities (even if they're a bit buggy). I wish to ask for your help in articulating (both to myself, and for my future audience) W...
Can the poisson distribution be used to analyze continuous data as well as discrete data? I have a few data sets where response variables are continuous, but resemble a poisson distribution rather than a normal distribution. However, the poisson distribution is a discrete distribution and is usually concerned with numb...
I’m reviewing an article, and can’t give details but here is the situation, and it’s got me puzzled Patients were divided into 4 categories (call them A B C and D), which were exhaustive and exclusive. Adjusted hazard ratios were computed for these four groups for all patients and for two subgroups of patients (call t...
Can we do a meta-analysis of data of 3 regions. A particular disease was treated with the same treatment but implemented thoroughly in 2 regions and not so thoroughly in 1 region. How to proceed with analysis? What is the best way to analyse these data. The data are of a disease (cases and deaths) as follows: ...
readHTMLTable seems pretty robust, but when I try to use it on this page, I get an error. Any ideas what it means or how I could get around it? The page's biggest table is nested inside another table... is that a problem? > tables<-readHTMLTable(myURL, header=NA,a.data.frame=TRUE) Error in htmlParse(doc) : error...
I would like to get the coefficients for the LASSO problem $$||Y-X\beta||+\lambda ||\beta||_1.$$ The problem is that glmnet and lars functions give different answers. For the glmnet function I ask for the coefficients of $\lambda/||Y||$ instead of just $\lambda$, but I still get different answers. Is this expected? Wh...
I have three features that I use to solve a classification problem. Originally, these features produced boolean values, so I could evaluate their redundancy by looking at how much the sets of positive and negative classifications overlap. Now I have extended the features to produce real values (scores) instead, and I w...
I am managing many people entering data into a database. I have a log of user, date, time, table, and action that each person makes: records <- data.frame(user = c('bob', 'bob', 'jane', 'jane', 'bob', 'bob', 'bob', 'jane', 'jane', 'bob'), date = c("2010-06-24", "2010-06-28", "2010-06-29", "2010-06...
Given two basketball players. John made 38/50 free throws. Mike made 80/100 free throws. What is probability that Mike is better at free throws than John?
Is it possible to correct for violating the assumption of independence for nonparametric tests? I have a categorical independent variable and a categorical and binary dependent variable, and each subject was exposed to multiple levels of treatment. I have done some preliminary analysis with binary logistic regression ...
What is the best way of defining white noise process so it is intuitive and easy to understand?
Is there a formal statistical test to test if process is a white noise?
How do you carry out analysis of covariance using R? How do you interpret the results? A practical example will be highly appreciated.
Background: In connection with the question here I came upon a more interesting question. I believe the question is large and distinct enough to have it's own thread. Of course I might be mistaken, in that case I apologize for the clutter... I have a dataset of experimental values, coming from an unknown distribution. ...
I am doing some class work and I was wondering if there is a universally accepted format for analyzing and presenting the data in a Word document for data gathered from questionnaires.
I need a formula for the probability of an event in a n-variate Bernoulli distribution $X\in\{0,1\}^n$ with given $P(X_i=1)=p_i$ probabilities for a single element and for pairs of elements $P(X_i=1 \wedge X_j=1)=p_{ij}$. Equivalently I could give mean and covariance of $X$. I already learned that there exist many $\{...
When generating survival times to simulate Cox proportional hazards models, does it matter to generate them in days or in years? In theory, I guess it does not matter. But in practice? Is there a preference regarding computational issues? Thank you! Marco
Does anybody know whether R has a package/routine for estimating spline function with unknown number of knots?
I am doing research and trying to use a questionnaire that is available in English in another language. Is there a systematic approach for validating a questionnaire in another language? What statistical test should I be undertake and why?
I am interested in applying Bayesian additive regression trees (BART) for classification analysis of gene expression data. I am relatively new to R (and Bioconductor packages) and I am unable to find some code or vignette that I can use to learn from. I will be thankful if someone can point me in a good direction.
I'm fitting a 4 parameter nonlinear regression model to multiple datasets, some of which fail to converge, however, the parameters output after a failure provide a fit that looks good, if not exceptional to my (and other's) eyes. I've explored convergence criteria and they do converge eventually but the visual fit is t...
Example of problem: Part of our research team is working on providing operationally wind power forecast. Usually, since there are different time scalse that interest forecast user, a forecast is issued every 15 min (it has even happened that 5 seconds was requirer) for every 15 minutes ahead up to serveral days. Obviou...
What is/are the difference(s) between a longitudinal design and a time series?
To perform principal component analysis (PCA), you have to subtract the means of each column from the data, compute the correlation coefficient matrix and then find the eigenvectors and eigenvalues. Well, rather, this is what I did to implement it in Python, except it only works with small matrices because the method t...
I have 2 simple questions about linear regression: When is it advised to standardize the explanatory variables? Once estimation is carried out with standardized values, how can one predict with new values (how one should standardize the new values)? Some references would be helpful.
I'm wondering how far along the natural language processing is in determining the semantic distance between two excerpts of text. For instance, consider the following phrases Early today, I got up and washed my car. I cleaned my truck up this morning. Bananas are an excellent source of potassium. Clearly (to the huma...
Study: I simulated some surfaces materials at audio and haptic level, and I asked subjects to evaluate on a 9-point Likert scale the degree of coherence between the two stimuli. For example there are stimuli with metal at auditory level and snow at haptic level, or wood both at auditory and haptic level. So it is like ...
When presenting data using a percentage, is it a good thing to have decimal places, say 2 decimal places instead of rounding off to whole numbers? For example, instead of 23.43%, you round off to 23%. I am looking at this from the perspective of whether the 2 decimal places accuracy will make much difference since we a...
When conducting a t-test we can always use a Welch approximation of the df, and let go of the assumption of equal variances. Is there something similar for (even one way) anova? (any R implementation of that?)
Sometimes in reports I include a disclaimer about the p-values and other inferential statistics I've provided. I say that since the sample wasn't random, then such statistics would not strictly apply. My specific wording is usually given in a footnote: "While, strictly speaking, inferential statistics are only a...
I came across this study as part of a mock exam paper and was confused to say the least. Context: The study investigates cognitive and behavioural factor related to the experience of anxiety in MRI scanners. Participants completed the following questionnaires 5 mins after the scan: a measure of the frequency of anxiet...
Suppose I draw $n$ observations $X_1,X_2,\ldots,X_n$ independently from a distribution where $X_i \sim \mathcal{N}(\mu_i,\sigma^2)$, where the mean is assumed to be Lipschitz: $\left| \mu_i - \mu_{i+1}\right| \le \gamma,$ with $\gamma$ known. I want to test the null hypothesis: $$H_0: \mu_n = 0$$ against the local alt...
Hi i am analaysing wind data for estimating energy from a wind turbine. I have taken 10 years of wind data and graphed a histogram; my second stage was to fit a Weibull distribution to the data. I used R with the package lmom to compute the Weibul shape and scale this is the code i used: >library(lmom) wind.moment...
How should you deal with a cell value in a contingency table that is equal to zero in statistical calculations? (Note that such a value can be structural, i.e., it must be zero by definition, or random, i.e., it could have been some other value, but zero was observed.)
I would like to have a good idea on how to design clinical trials in oncology. In that issue, I am looking for a compact book that could give me a good overview, with the emphasis on statistical considerations. Would you have a recommendation for me? Thank you in advance, Marco
People often talk about dealing with outliers in statistics. The thing that bothers me about this is that, as far as I can tell, the definition of an outlier is completely subjective. For example, if the true distribution of some random variable is very heavy-tailed or bimodal, any standard visualization or summary s...
I have a dataset with yearly levels of corruption in a number of countries, as well as whether they changed their government that year. year, corruption, change of president 2001, 5, 0 2002, 7, 1 2003, 8, 0 etc. I want to test whether corruption is affected by a change in power (defined as the election of a new presid...
I have a logistic regression model: $softmax(WX)$ where $W$ is my parameter matrix and $X$ is my input. I want a density function over the outputs of that model. Say I know that my $X$ are distributed according to some density $p$. From the change of variables I know that the density of the outputs will be something li...
What book is the most thorough treatment of fundamental concepts in statistics? I am not asking for a book on details of the methods of calculations and procedures, I am mainly interested in a book that thoroughly explains the foundational concepts ... an intuitive/illustrated/visual approach to the core ideas ... rat...
a friend of mine has asked me to help him with predictive modelling of car traffic in a medium sized parking garage. The garage has its busy and easy days, its peak hours, dead hours opening hours (it is opened during 12 hours during weekdays and during 8 hours during weekends). The goal is to predict how many cars wi...
I have a case-control study in which the cases are firms with health insurance and the controls are firms with no health insurance. I am studying the factors affecting enrolment in health insurance and was therefore using a logistic regression, which includes several covariates on firm characteristics that were measure...
I'm experimenting with classifying data into groups. I'm quite new to this topic, and trying to understand the output of some of the analysis. Using examples from Quick-R, several R packages are suggested. I have tried using two of these packages (fpc using the kmeans function, and mclust). One aspect of this analysis...
Everything I've read about combining errors in quadrature when multiplying or dividing quantities with associated errors says that this works for "small error". What about large error? Say I want to compute A/B where A is +/- 1% and B is +/- 50%, can I still reasonably add the errors in quadrature?
Sorry if this is similar to another question, but I'm still trying to learn data analysis and I don't know what to search for. What I'd like to do is take some information that a potential customer enters into a web form and figure out the probability that they'll become a customer... giving our sales team an idea of w...
I have a dataset of project case studies for a new type of research method for Government agencies to support decision making activities. My task is to develop an estimation method based on past experience for future projects for estimation purposes. My dataset is limited to 50 cases. I have 30+ (potential) predictor...
Can anyone tell me the difference between using aov() and lme() for analyzing longitudinal data and how to interpret results from these two methods? Below, I analyze the same dataset using aov() and lme() and got 2 different results. With aov(), I got a significant result in the time by treatment interaction, but fitti...
I have a set of integer that I am trying to see use different methods to categorize them into four groups, and the 2x2 table for the outcome of the 2 methods is displayed as below: method_B method_A 0 1 2 3 0 182 11 0 0 1 41 127 2 0 2 0 12 1...
The data I want to analyze consist of set of votes similar to the voting system here on stackexchange. Votes are binary, i.e, items can receive up- or down-votes. The data have been gathered in an A/B controlled experiment. I want to compare the control group to the treatment group according to some gold standard. Tha...
I'm looking for sample R code, or pointers to sample R code for the following. (Gentle) critique of the approach would also be appreciated. I'm not a statistician and I'm pretty new to R. I have duration of hospitalization ("length of stay"=LOS) data for 2,000 patients from my hospital and 50,000 patients from a comp...
I know that an easy to handle formula for the CDF of a normal distribution is somewhat missing, due to the complicated error function in it. However, I wonder if there is a a nice formula for $N(c_{-} \leq x < c_{+}| \mu, \sigma^2)$. Or what the "state of the art" approximation for this problem might be.
Context: I have "pooled data" with time and cross section dimensions. It is unbalanced data without a full range of time observations for each cross section of observations. It is kind of like unbalanced panel data? I wish to proceed with the limited number of observations without losing any data. Questions: How...
I understand the formal differences between them, what I want to know is when it is more relevant to use one vs. the other. Do they always provide complementary insight about the performance of a given classification/detection system? When is it reasonable to provide them both, say, in a paper? instead of just one? ...
I am using Cohen's Kappa to calculate the inter-agreement between two judges. It is calculated as: $ \frac{P(A) - P(E)}{1 - P(E)} $ where $P(A)$ is the proportion of agreement and $P(E)$ the probability of agreement by chance. Now for the following dataset, I get the expected results: User A judgements: - 1, true ...
My aim is to predict quarterly customer-default probabilities: I have data on ~ 2 million individuals, who default on average with a probability of ~ 0.3 percent. Therefore I am thinking about undersampling the majority class (non-defaults) to save computing-time (kernel methods can be quite costly, I know about correc...
Can you recommend a text mining package in R that can be used against large volumes of data? Secondly, is there a GUI available for any of the text mining packages in R? Thirdly, is there another open source text mining program that is easy and intuitive to use?
Suppose I have a large population of data points $(x,y)$ and that the Pearson's correlation is $$\textrm{corr}(X,Y) = \rho$$ What can I reasonably say about the correlation I expect to observe in a sample of size $n$? If the sample correlation is $\rho_s$, roughly what is the spread is $\rho_s$? Is $\rho_s$ biased? ...
I would like to pose this question in two parts. Both deal with a generalized linear model, but the first deals with model selection and the other deals with regularization. Background: I utilize GLMs (linear, logistic, gamma regression) models for both prediction and for description. When I refer to the "normal things...
I'm working on a little project involving the faces of twitter users via their profile pictures. A problem I've encountered is that after I filter out all but the images that are clear portrait photos, a small but significant percentage of twitter users use a picture of Justin Bieber as their profile picture. In order ...
I am using the R package penalized to obtain shrunken estimates of coefficients for a dataset where I have lots of predictors and little knowledge of which ones are important. After I've picked tuning parameters L1 and L2 and I'm satisfied with my coefficients, is there a statistically sound way to summarize the model ...
How to interpret residuals in random and fixed effects models? I am a medical doctor. Kindly explain in simple words. Updated Here is an example: Weight (Fixed) Weight (Random) Residual (Fixed) Residual (Random) Relative weight Relative weight Std Residual Std Residual 32.27 ...
I've got a dataset similar to this: pat_id epis Care Type 1 1722650 Acute Care 1 1723120 Rehabilitation care 2 1584309 Acute Care 2 1585705 Rehabilitation care 3 1726487 GEM 3 1664031 Acute Care 3 1726488 Acute Care 3 1726489 Rehabilitation care Each patient has multip...
I have two vectors of matching lengths. They are readings from two different sensors (one is from a smartphone and the other is from a wiimote) of the same hand movement. I am trying to find the time offset between them to synchronise the readings for further processing. The readings I get are of the format (Time(ms) V...
I am fitting a simple linear regression model with R & JAGS: model { for (i in 1:length(ri)){ ri[i] ~ dnorm(mu[i],tau) mu[i] <- alpha + b.vr*vr[i] + b.ir*ir[i] } #posterior predictive distribution for (j in 1:length(pvr)){ pmu[j] <- alpha + b.vr*pvr[j] + b.ir*pir[j] pri[...
I do not know if this has been asked before, but I do not found anything about it. My question is if anyone can provide a good reference to learn how to obtain the proportion of variance explained by each one of the fixed and random factors in a mixed-effects model.
Lets say I have a website which gets 100 hits per day (mu = 100). Yesterday my website got 130 hits (x = 130). If I assume a Poisson distribution, then the probability of getting 130 hits is: > dpois(130, 100) [1] 0.0005752527 # about 0.06% So this tells me that getting 130 hits is quite unusual for my website due to ...
It seems non-convexity of loss function is not such a problem for boosting with a normalized sigmoid loss function. Do you know any further work showing better results with this kind of boosting than Adaboost (exponential loss function)? Here are the graphs of different loss functions adapted from the graphs shown in A...
I was wondering if there is a free tool to build a decision tree in interactive fashion like in SAS Enterprise Mining. I'm used to work with Weka. But nothing fits to my needs. I would like that before splitting every node, the program asks to user which attribute (maybe from a list of the "best" attributes) to choose....
I'm having difficulty understanding one or two aspects of the cluster package. I'm following the example from Quick-R closely, but don't understand one or two aspects of the analysis. I've included the code that I am using for this particular example. ## Libraries library(stats) library(fpc) ## Data mydata = structur...
Framework. Fix $\alpha\in ]0,1[$. Imagine you have $n$ $\alpha$-quantile forecast methodologies that give you, at time $t$ for look ahead time $t+h$, an estimation of the quantile of wind power. Formally, for $i=1,\dots,n$, you know how to produce $\hat{q}_{t+h|t}^{(i)}$ at time $t$ for look ahead time $t+h$ an estimat...