Yes, Puerto Rico is part of the USA for immigration purposes, as is every US territory and possession. You can stay there as long as you wish. In fact, many green card holders live in Puerto Rico and other US territories.
From the USCIS document M-618 (rev. 09/15) Welcome to the United States A Guide for New Immigrants:
The United States now consists of 50 states; the District of Columbia (a special area that is the home of the federal government); the territories of Guam, American Samoa, and the U.S. Virgin Islands; and the Commonwealths of the Northern Mariana Islands and Puerto Rico.
There are a few other minor outlying possessions (such as some protected Pacific islands) which are also part of the USA but traveling to such places requires special permission. They aren’t mentioned because travel to them is extremely rare, and in most cases no one at all lives there, but as they are part of the USA they still count.
Note that many US territories and possessions have different customs and agriculture/biosecurity rules than the mainland US, but this does not affect your immigration status.
Note also that you should bring your green card and passport if you travel to or from Puerto Rico or the US Virgin Islands. While this is a purely domestic flight, and it is not strictly required for you to have your passport, if the flight has an emergency it may need to divert to an airport at an island which is not part of the USA. You will need your travel documents if this happens.