Porosity Logs Author s. Resistivity Logs Author s. Nuclear Magnetic Resonance Logging Author s. Steven Henderson Steven Henderson. Log Interpretation Author s. Petrophysical Techniques Author s.
Borehole Images Author s. Log Interpretation Case Studies Author s. View Full GeoRef Record. Citing Books via Google Scholar. Close Modal. Get Permissions. Abstract The next class of well logs to be considered is generally referred to as porosity logs.
You do not currently have access to this chapter. You could not be signed in. Librarian Administrator Sign In. Buy This Chapter. George Asquith ; George Asquith. Daniel Krygowski ; Daniel Krygowski. Steven Henderson ; Steven Henderson. American Association of Petroleum Geologists.
Publication date:. Citing Books via Google Scholar. Close Modal. One of these series has partial autocorrelations and one does not. Lag values whose lines cross above the dotted line are statistically significant. In the first time series Figure As with autocorrelation, however, that is just an initial estimate and must verified by fitting and diagnosing the model.
The second time series Figure Use the Ccf function from the package forecast to plot the cross-correlation function, which will reveal lagged correlations:. The cross-correlation function helps you discover lagged correlations between two time series. Consider the relationship between commodity prices and bond prices. Some analysts believe those prices are connected because changes in commodity prices are a barometer of inflation, one of the key factors in bond pricing.
Can we discover a correlation between them? Note that since the objects we start with, bonds and cmdtys , are xts objects, we extract from each the vector of data using coredata [1]. This is because the Ccf function expects inputs to be simple vectors.
Every vertical line shows the correlation between the two time series at some lag, as indicated along the x-axis. If a correlation extends above or below the dotted lines, it is statistically significant. Notice that the correlation at lag 0 is —0. Much more interesting are the correlations at lags 1, 5, and 8, which are statistically significant. Discovering this sort of relationship is useful to short-term forecasters such as market analysts and bond traders.
Use linear regression to identify the trend component, and then subtract the trend component from the original time series. These two lines show how to detrend the zoo object ts and put the result in detr :. Some time series data contains trends, which means that it gradually slopes upward or downward over time. Suppose your time series object a zoo object in this case , yield , contains a trend as shown in Figure We can remove the trend component in two steps.
First, identify the overall trend by using the linear model function, lm. The model should use the time series index for the x variable and the time series data for the y variable. Second, remove the linear trend from the original data by subtracting the straight line found by lm. We can extract the residuals from the linear model by using the resid function and then embed the residuals inside a zoo object:. Notice that we use the same time index as the original data.
When we plot detr it is clearly trendless, as evident in Figure So detr is the difference between actual yield and the trend.
Sometimes when detrending you may want to determine the percent deviation from the trend. In that case we can divide by the initial measure:. The top plot in Figure The auto.
If you already know the model order, p , d , q , then the arima function can fit the model directly:. The model order is usually denoted by three integers, p , d , q , where p is the number of autoregressive coefficients, d is the degree of differencing, and q is the number of moving average coefficients.
Rather than tediously searching for the best combination of p , d , and q , we typically use auto. In this case, auto. In addition, the auto. The seasonality terms are similar to the nonseasonal ARIMA terms, but relate to the seasonality component of the model. The m term tells us the periodicity of the seasonality, which in this case is quarterly. We can see this easier if we plot the ausbeer data as in Figure By default, auto. If you are confident that your model needs fewer than five coefficients, use the max.
Likewise, if you believe that your model needs more coefficients, use max. If you want to turn off the seasonality component of auto. But notice that since the model fits a nonseasonal model, the coefficients are different than in the seasonal model.
If you already know the order of your ARIMA model, the arima function can quickly fit the model to your data:. The output looks identical to auto.
The output from auto. This output illustrates a major headache of ARIMA modeling: not all the coefficients are necessarily significant. If one of the intervals contains zero, the true coefficient might be zero itself, in which case the term is unnecessary. If you discover that your model contains insignificant coefficients, use Recipe For example, you can force them to include or exclude a trend component.
See the help pages for details. A final caveat: the danger of auto. ARIMA modeling is not simple. It is more art than science, and the automatically generated model is just a starting point. As a textbook on time series forecasting, we highly recommend Forecasting: Principles and Practice by Rob J.
Hyndman and George Athanasopoulos which is freely available online. You want to remove them. The arima function includes the parameter fixed , which is a vector. The vector should contain one element for every coefficient in the model, including a term for the drift if any.
Each element is either NA or 0. Use NA for the coefficients to be kept and use 0 for the coefficients to be removed. The fpp2 package contains a dataset called euretail , which is a quarterly retail index for the Euro area. We can set this parameter to 0 using the fixed parameter:. Observe that the ma1 coefficient is now 0. The remaining coefficients ma2 , ma3 , sma1 are still significant, as shown by their confidence intervals, so we have a reasonable model:.
You have built an ARIMA model using the forecast package, and you want to run diagnostic tests to validate the model. Use the checkresiduals function. The result of checkresiduals is a set of three graphs, as shown in Figure A good model should produce results like these:.
The p -value in the Ljung—Box test is large, indicating that the residuals are patternless—meaning all the information has been extracted by the model and only noise is left behind. For contrast, Figure The p -values for the Ljung—Box statistics are small, indicating there is some pattern in the residuals.
There is still information to be extracted from the data. These are basic diagnostics, but they are a good start. Find a good book on ARIMA modeling and perform the recommended diagnostic tests before concluding that your model is sound. Additional checks of the residuals could include:. You want to forecast the next few observations in the series.
Save the model in an object, and then apply the forecast function to the object. This example saves the model from Recipe The forecast function will calculate the next few observations and their standard errors according to the model.
It returns a list with 10 elements. If we want to extract out just the forecast, we can do that by assigning the results to an object, and then pulling out the list item named mean :. The result is a Time-Series object containing the forecasts created by the forecast function. You have created a time series forecast with the forecast package and you would like to plot it. Time series models created with the forecast package have a plotting method that uses ggplot2 to create graphs easily, as shown in Figure The autoplot function makes a very reasonable figure, as shown in Figure Since the resulting figure is a ggplot object, we can adjust the plotting parameters the same way we would any other ggplot object.
Here we add labels and a title and change the theme, as shown in Figure The output from adf. When a time series is mean reverting, it tends to return to its long-run average. It may wander off, but eventually it wanders back. If a time series is not mean reverting, then it can wander away without ever returning to the mean. The large p -value from the adf.
The time series in Figure The small p -value 0. The example data here comes from the fpp2 package and comprises all Time-Series object types. If your data were in a zoo or xts object, then you would need to call coredata to extract out the raw data from the object before passing it to adf.
The adf. First it automatically detrends your data, and then it recenters the data, giving it a mean of 0. If either detrending or recentering is undesirable for your application, use the adfTest function in the fUnitRoots package instead:.
Both the adf. These functions provide reasonable defaults, but serious users should study the textbook description of the ADF test to determine the appropriate lag for their application. The urca and CADFtest packages also implement tests for a unit root, which is the test for mean reversion. Be careful when comparing the tests from several packages.
Each package can make slightly different assumptions, which can lead to puzzling differences in the results. The KernSmooth package contains functions for smoothing. Use the dpill function to select an initial bandwidth parameter, and then use the locploy function to smooth the data:.
The KernSmooth package is a standard part of the R distribution. It includes the locpoly function, which constructs, around each data point, a polynomial that is fitted to the nearby data points. These are called local polynomials. The local polynomials are strung together to create a smoothed version of the original data series. The algorithm requires a bandwidth parameter to control the degree of smoothing. A small bandwidth means less smoothing, in which case the result follows the original data more closely.
A large bandwidth means more smoothing, so the result contains less noise. The tricky part is choosing just the right bandwidth: not too small, not too large.
Fortunately, KernSmooth also includes the function dpill for estimating the appropriate bandwidth, and it works quite well. We recommend that you start with the dpill value and then experiment with values above and below that starting point.
There is no magic formula here. You need to decide what level of smoothing works best in your application. The following is an example of smoothing. Both dpill and locpoly require a grid size—in other words, the number of points for which a local polynomial is constructed. We often use a grid size equal to the number of data points, which yields a fine resolution. The resulting time series is very smooth. You might use a smaller grid size if you want a coarser resolution or if you have a very large dataset:.
The locpoly function performs the smoothing and returns a list. The y element of that list is the smoothed data:. In Figure The figure demonstrates that locpoly did an excellent job of extracting the original sine wave. The ksmooth , lowess , and HoltWinters functions in the base distribution can also perform smoothing. The expsmooth package implements exponential smoothing. The data was taken from the period through R Cookbook, 2nd Edition.
Note The xts implementation is a superset of zoo , so xts can do everything that zoo can do. Other Representations Other representations of time series data are available in the R universe, including: fts package irts from the tseries package timeSeries package ts base distribution tsibble package, a tidyverse style package for time series In fact, there is a whole toolkit, called tsbox , just for converting between representations. Two representations deserve special mention.
For example, if x is an xts object, you can compute its autocorrelation like this: acf as. Date Versus Datetime Every observation in a time series has an associated date or time.
See Also R has many useful functions and packages for time series analysis. Solution We recommend the zoo and xts packages.
Discussion R has at least eight different implementations of data structures for representing time series.
0コメント