Question

How would I use given data to generate lags? For example, I am given the variable...

How would I use given data to generate lags? For example, I am given the variable DMortgage. How would I generate lags of DMortgage(t): DMortgage (t-1), DMortgage (t-2), DMortgage (t-3), and DMortgage (t-4)?

Homework Answers

Answer #1

In STATA

Create lag (or lead) variables using subscripts.

        . gen lag1 = x[_n-1]
        . gen lag2 = x[_n-2]
        . gen lead1 = x[_n+1]

You can create lag (or lead) variables for different subgroups using the by prefix. For example,

        . sort state year 
        . by state: gen lag1 = x[_n-1]

In R

Lag a Time Series

Description

Compute a lagged version of a time series, shifting the time base back by a given number of observations.

lag is a generic function; this page documents its default method.

Usage

lag(x, ...)

## Default S3 method:
lag(x, k = 1, ...)

Arguments

x

A vector or matrix or univariate or multivariate time series

k

The number of lags (in units of observations).

...

further arguments to be passed to or from methods.

lag {stats} R Documentation
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am aware the data is not given. HOW DO I UPLOAD THE DATASET IN ORDER...
I am aware the data is not given. HOW DO I UPLOAD THE DATASET IN ORDER FOR YOU TO ANSWER THE FOLLOWING QUESTION: I have chosen three variables from the GSS2014sample.sav SPSS data set for you to use to create two bivariate comparisons. The variable names and labels are listed below. Identify the correct level of measurement for each one. Complete the table, list the categories in the frequency table for each variable, then continue to the questions that follow....
How do I use transformations to generate directly a random variable with a Student's t distribution...
How do I use transformations to generate directly a random variable with a Student's t distribution with v degrees of freedom?
1. I am interested in studying income equality between men and women in the workplace. What...
1. I am interested in studying income equality between men and women in the workplace. What would be a reasonable null and alternative hypothesis? 2. Give an example of one discrete random variable and one continuous random variable. 3. I am doing a t-test to determine whether a generic drug was less effective then a name-brand drug. What is the critical value if I have collected data from 12 individuals and am using a significance level of 1%? 3.11 -3.11...
Working with Python! I am trying to use matplotlib on the jupyter notebook to graph a...
Working with Python! I am trying to use matplotlib on the jupyter notebook to graph a smooth curve scatter plot from data points in a dictionary like this, for example, and the positions of x and y are (x,y) sampleData = {"sample 1": ('3','5'), "sample 2": ('2','1'), "sample 3": ('2','2'), "sample 4":('6','7')}
What descriptive statistics will be used for preliminary data analysis? This is an example of how...
What descriptive statistics will be used for preliminary data analysis? This is an example of how the answer would look like. Example 1: Frequency Distribution table (Numerical description) and Bar Chart for the Gender variable (Graphical description) .    Example 2: Mean and Standard Deviation (Numerical description) and the histogram and boxplot (Graphical description) for the Age variable . I did a research project and my hypothetical statement was the mean stress scores for non-traditional students will be significantly different...
In statistics, if I am 64inches, how would I calculate the percentage of people that are...
In statistics, if I am 64inches, how would I calculate the percentage of people that are within 2 inches of my height? mean: 63.7 Sx: 2.7
I have a linear regression project for class and am having trouble doing the T-test. I...
I have a linear regression project for class and am having trouble doing the T-test. I gathered data and now I'm just wondering how I would determine my hypothesis. Is it based on a p-value, do I have to find the t-statistic? I'm confused as in given problems the hypothesis is given? I know the level of significance is .10, so would that be my hypothesis (ho: beta =.10)?
How can I find angular frequency if I am given force, displacement, and velocity at equilibrium...
How can I find angular frequency if I am given force, displacement, and velocity at equilibrium if I am NOT given mass? Simple Harmonic motion
I am to create a scatter plot with two sets of data (there is a lot...
I am to create a scatter plot with two sets of data (there is a lot more data than what is posted below but the whole data set was too large to post).  I am then to complete a Pearson R test for significance and test for goodness of fit using R2. How do I create a scatter plot with the data? How do I complete the required tests of the data?   Score # BSN Pearson r 536.17 5 T .DIST...
Show how to use Metropolis Algorithm to generate a random variable with an approximate student’s t...
Show how to use Metropolis Algorithm to generate a random variable with an approximate student’s t distribution with v degrees of freedom, starting from N(0,1) random variables. (Not using programming codes)