# Tag Info

12

Basic OLS regression is a very good technique for fitting a function to a set of data. However, simple regression only fits a straight line that is constant for the entire possible range of $X$. This may not be appropriate for a given situation. For instance, data sometimes show a curvilinear relationship. This can be dealt with by means of regressing ...

11

This answer is in two main parts: firstly, using linear interpolation, and secondly, using transformations for more accurate interpolation. The approaches discussed here are suitable for hand calculation when you have limited tables available, but if you're implementing a computer routine to produce p-values, there are much better approaches (if tedious when ...

7

Suppose $\left(Z_0, Z_1, \ldots, Z_n\right)$ is a vector assumed to have a multivariate distribution of unknown mean $(\mu, \mu, \ldots, \mu)$ and known variance-covariance matrix $\Sigma$. We observe $\left(z_1, z_2, \ldots, z_n\right)$ from this distribution and wish to predict $z_0$ from this information using an unbiased linear predictor: Linear means ...

7

After clarification in a comment discussion, it appears that the question is about a situation where there is a linear model relating a continuous response variable $Y_i$ and a binary predictor $X_i \in \{0,1\}$, and the OP wants to know whether or not it is defensible to interpolate by plugging in values for $X_i$ that are $\in (0,1)$ and assuming ...

6

The zoo package is very good at that (as is xts which extends it). The zoo vignettes have e.g. this example: zr3 <- zooreg(rnorm(9), start=as.yearmon(2000), frequency=12) zr3 aggregate(zr3, as.yearqtr, mean) A (regular) series is created with monthly frequency, and the averaged by quarter. It works the very same way for POSIXct objects at much higher ...

6

Cosma Shalizi's online notes on his lecture course Advanced Data Analysis from an Elementary Point of View are quite good on this subject, looking at things from a perspective where interpolation and regression are two approaches to the same problem. I'd particularly draw your attention to the chapters on smoothing methods and splines.

6

Any form of function fitting, even nonparametric ones (that typically make assumptions on the smoothness of the curve involved), involves assumptions, and thus a leap of faith. The ancient solution of linear interpolation is one that 'just works' when the data you have is fine-grained 'enough' (if you look at a circle close enough, it looks flat as well - ...

6

Variography is part statistics, part science, and partly a practical art. Entire books (or major parts thereof) have been written about it, beginning with Journel & Huijbregts' Mining Geostatistics in 1978, so it will not be possible to do justice to this question in the space of one Web page. Let's just examine the issues briefly. What a variogram ...

5

One option may be to split the original data into two subsets: one that will be used in interpolating values and one that will be used to validate the interpolation results. The error is then estimated by comparing interpolated values at the validation point locations with the actual validation point values. Note that the appropriateness of this approach is ...

5

There is no need to do anything. An ARMA model can easily be estimated with missing values within the time series. You need to use the state space representation of an ARMA model to compute the likelihood. If you use R, this is already handled automatically via the arima() function.

5

An early paper to this effect is Evan Englund's A Variance of Geostatisticians (Math. Geo. 1990) in which irregularly sampled elevation data from the Walker Lake area of Nevada were transformed and given to a dozen statisticians for interpolation using whatever methods they preferred. The results varied widely and the best ones were not obtained by kriging, ...

5

I have managed to create an R function that interpolates even-spaced points linearly and with splines while preserving the means (e.g. weekly, monthly, etc.). It uses the functions na.approx and na.spline from the zoo package and iteratively calculates the splines with the desired properties. The algorithm is described in this paper. Here is the code: ...

4

It sounds to me like an interpolated raster "heat map" may be what you are looking for. I typically use the spatstat library for analysis of point patterns, so here is an example using that library. Here I use inverse distance weighting, but whether that is appropriate or not I would need more domain knowledge. set.seed(10) library(spatstat) ...

4

You need more data for a spline fit. mgcv indeed is a good choice. For your specific request you need to set the cubic spline as the basis function bs='cr' and also not have it penalized with fx=TRUE. Both options are set for a smooth term that is set with s(). Predict works as expected. library(mgcv) x <- data.frame(a = 1:100, b = 1:100/2, c = 1:100*2) ...

4

The first thing to do, if possible, is to take care of the heteroscedasticity. Notice how the spread of the residuals consistently increases with the fit: in fact, the spread seems to increase almost quadratically with larger fit. A standard cure is to return to the original response ($log(xy)$) and apply a strong transformation, such as a logarithm or ...

4

Any straight line that goes through the mean at the midpoint of the range will produce daily values that have the required mean. Nick Cox's last comment about 'divide weekly counts by number of days' is a special case of that with gradient=0. So we can adjust this and choose the gradient to make things perhaps a bit smoother. Here's three R functions to do ...

3

Check out the akima package's interp. These functions implement bivariate interpolation onto a grid for irregularly spaced input data. Bilinear or bicubic spline interpolation is applied using different versions of algorithms from Akima. Usage interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), ...

3

The EDF is the CDF of the population constituted by the data themselves. This is exactly what you need to describe and analyze any resampling process from the dataset, including nonparametric bootstrapping, jackknifing, cross-validation, etc. Not only that, it's perfectly general: any kind of interpolation would be invalid for discrete distributions.

3

I'll bundle together some extra comments as another answer. It's taken a while for the structure of this project to become clearer. Given that influenza is now revealed as one covariate among several, quite what you do it with doesn't seem so crucial, or at least not to merit the scepticism expressed in some of my earlier comments. As everything else is on ...

2

I tend to use Gaussian process models for this and similar surface estimation (Possible relevant examples here and here). But perhaps your question would be best asked over on Stack Overflow? Could you provide more details on your input data (contours from a surface model of MRI data?) as well as your desired outputs: scale parameter which minimizes L2 ...

2

I have brief answers to the two points in your question, and encourage you to see the reference below for details. Most surface estimation algorithms estimate a point cloud P' to approximate the input set P. The point to point distance between the estimated point and corresponding input point may suffice for your error metric. You are seeking a ...

2

Multiple imputation is an important and common practice. Assuming your data are normally distributed and missing more or less at random, I would recommend you impute the missing values. A good package that I use quite frequently is Amelia for R. http://gking.harvard.edu/amelia/ The package uses various probabilistic methods to impute the missing values, and ...

2

Of course I agree with Macro here. These are two entirely different models. The coefficient for an indicator variable would bear no relation to what the coefficient should have been had you fit the model with a continuous variable. If you have data on the continuous variable you would be better off fitting the model to that. By dichotomizing the variable ...

2

The main difference between interpolation and regression, is the definition of the problem they solve. Given $n$ data points, when you interpolate, you look for a function that is of some predefined form that has the values in that points exactly as specified. That means given pairs $(x_i, y_i)$ you look for $F$ of some predefined form that satisfies ...

2

Hopefully this will come rather quickly with a simple example and visualization. Suppose you have the following data: X Y 1 6 10 15 20 25 30 35 40 45 50 55 We may use regression to model Y as a response to X. Using R: lm(y ~ x) The results are an intercept of 5, and a coefficent for x of 1. Which means an arbitrary Y can be calculated for a given X ...

2

There has been lots of work regarding the use of sinus cardinal function as a kernel for density estimation. Most of the work involving sinc kernels is actually for density deconvolution in error-in-variable models because the Fourier transform has a compact support and because it enjoys nice computational properties. In terms of implementations there is an ...

2

(assuming you want to use python) The easiest (given what's currently available) would be to use a polynomial and robust methods from statsmodels. something like endog = y # observed points, one dimensional array #polynomial array as explanatory variable: #assuming x contains the vertical points x = x / float(x.max() - x.min()) * 2 - 1 #optional ...

2

Regarding the choice of block size in block kriging: "Experience has shown is best to keep the blocks approximately the same size as the separation between the samples" [AM89]. In the same text the author also comments that it is important not only to carefully look at the block size but also the layout of your sample's locations and also highlights in more ...

2

I am no expert on Fourier transforms, but... Epstein's total sample range was 24 months with a monthly sample rate: 1/12 years. Your sample range is 835 weeks. If your goal is to estimate the average for one year with data from ~16 years based on daily data you need a sample rate of 1/365 years. So substitute 52 for 12, but first standardize units and ...

1

Given your clarification, I would say you can perfectly do posterior sampling with MCMC with an interpolated model. Obviously, you have to be aware that your posterior is then conditioned on your interpolated version of your model. If this interpolation includes some differences with respect to the original model (induced by the interpolation), you are ...

Only top voted, non community-wiki answers of a minimum length are eligible