I have time-series cross-section data (a balanced panel) with multiple markets and mutiple weeks for each market. I have the spatial location coordinates for each market as (latitude longitude). So the data look like this (these are made up):
Market latitude longitude Week Y X
23 8.73 77.53 1 34 11
23 8.73 77.53 2 21 12
23 8.73 77.53 3 62 14
24 6.73 87.53 1 24 9
24 6.73 87.53 2 45 8
24 6.73 87.53 3 71 14
......
I would like to model the spatial covariance in the error between markets, as a function of spatial proximity. I tried the following program:
proc mixed;
model y = x;
repeated week/subject = market type = sp(exp)(latitude longitude);
run;
The error this produces is "a nonpositive definite estimated R matrix for subject 1". I think this is happening because (latitude longitude) is repeated within subject. But I cannot figure out how to specify the model so I can allow for covariance between markets, as a function of (latitude longitude). Any suggestions greatly appreciated.
I'm not even sure you would get spatial covariance use lat/long, regardless of the nonpositive definite matrix. Just specifying lat/long menas you think there is an east/west or north/south (or combination) trend over your study region. But aren't you really interested in the spatial analog of serial autocorrelation? I mean, isn't it "economic distance from competing/cooperationg markets" that you care about? I don't know if you're really interested in estimating the impact of other markets, or just eliminating that impact to assess other relations, but I don't see how lat/long will help with either objective.
Without getting into robust spatial analysis (see https://support.sas.com/rnd/app/stat/procedures/SpatialAnalysis.html), I think you're just trying to get the impact of distance from other markets on each given market. Or more likely, just the impact of the nearest markets.
I'm just speculating here, but ...
At least this approach would unburden you of the fixed lat/long values for each market.
First I hadn't been aware of the type=sp parameter. And I think you're right about what it supposed to do for you - namely get spatial autocorrelation. I've looked at some examples of proc mixed with "type=sp" and I can't find any that treats your situation - constant lat/long with a subject.
This goes beyond my depth of understanding, but does this link (http://www.ats.ucla.edu/stat/sas/faq/spatial_reg.htm) offer any possibilty? It uses "/subject=intercept", and then uses a type=sp. If you have a time variable, would it work if you used time as a third spatial dimension?
"repeated / subject=intercept type=sp(expa) (time lat long)"
I use "expa" instead of "exp", because the SAS documentation states that EXP is two-dimensional. EXPA allows more dimensions.
And yes, in the absence of a solution using "type=sp", I was proposing Y_m' as a predictor.
Thank you, mkeintz.
The ats.ucla link that you provided led me to this reference book
http://ebooks.cawok.pro/SAS.Publishing.SAS.for.Mixed.Models.2nd.Edition.Mar.2006.pdf
that seems to have a very detailed chapter 11 on using Proc Mixed to estimate Spatial Covariance structures. I hope to find a solution there. I appreciate the input and help.
I'm quite curious to know the resolution of this problem. Please post it when you find one.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.