Hi everyone
I've been working on map plots in R lately, and want to advance to spatial regressions in Stata using the -spmap- package.
My aim is to do cross-sectional analysis. However, I am having some difficulties with formating my data correctly to -spset-.
I have a data set with 19 counties, longitude and latitude and two variables of interest. The variable "group" is used in R to group counites, e.g.
Although I only have 19 counties and observations from one year on my two variables of interest, the total data set has 82 112 observations in total, due to all the longitude and latitude observations.
I've tried to look up documentation on -spset-, but I have the impression that I need polygons for my counties for -spset- to work, and I wonder if I can work around this with my data set.
I'll add that I've discussed combining data set on a separate post.
I've been working on map plots in R lately, and want to advance to spatial regressions in Stata using the -spmap- package.
My aim is to do cross-sectional analysis. However, I am having some difficulties with formating my data correctly to -spset-.
I have a data set with 19 counties, longitude and latitude and two variables of interest. The variable "group" is used in R to group counites, e.g.
Code:
plot <- ggplot(data = Map_diag_and_med, aes(x=long, y = lat, group = group)) + geom_polygon(aes(fill = med))
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float county str6 group double(longitude latitude) float diag 1 "01.1" 10.68531156276028 59.48859956745566 4.55 1 "01.1" 10.692866471099695 59.490463187251976 4.55 1 "01.1" 10.696115331962785 59.493375407845775 4.55 1 "01.1" 10.708315889128597 59.490451533272335 4.55 1 "01.1" 10.713956978021121 59.4778906633188 4.55 1 "01.1" 10.718585124375561 59.47630827739814 4.55 1 "01.1" 10.720418520606842 59.4736656505165 4.55 1 "01.1" 10.72591715474232 59.471882092417836 4.55 1 "01.1" 10.73608854099581 59.47583202527449 4.55 1 "01.1" 10.741668744010008 59.47906380163044 4.55 end label values county county_n label def county_n 1 "Østfold", modify label var group "group" label var longitude "long" label var latitude "lat"
I'll add that I've discussed combining data set on a separate post.